从日期时间减去 1 年
我看过很多关于如何从一个日期时间中减去另一个日期时间以及如何在日期时间上添加年份的信息。但以下内容让我头疼......
当用户插入一条记录时,一个名为 subdate 且值为 datetime.now 的隐藏字段将添加到数据库中。
然后,我需要一个“旧记录”页面,列出所有超过 1 年的条目,并希望使用类似于以下内容的内容(但使用减法):
(DateTime.Now.AddYears(1))
但没有 SubtractYears 可用?为什么?
请问你能告诉我如何达到同样的结果吗?
I have seen a lot of info on how to subtract one datetime from the other and how to add years on to a datetime. but the following is giving me a headache....
When a user inserts a record a hidden field called subdate with a value of datetime.now is added to the db.
I then need to have an 'old records' page that lists all the entries that are over 1 year old and was hoping to use something (but using subtract method) similar to;
(DateTime.Now.AddYears(1))
but there is no SubtractYears available? Why?
Please can you let me know how I achieve the same result?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
来自文档:
From the documentation: