日期范围(以天为单位)...C#
我有一个从 C# 调用 Oracle DB 的查询。我想编写查询来获取最多 5 年的数据。
我目前有一个硬编码值 public const int FIVE_YEARS_IN_DAYS = 1825;
但是,由于闰年,这是不正确的。有没有一个函数可以给我过去 5 年的正确天数?
I have a query that is calling an Oracle DB from C#. I want to write the query to get data that is, at most, 5 years old.
I currently have a hard coded value for public const int FIVE_YEARS_IN_DAYS = 1825;
But, this isn't correct because of leap years. Is there a function that will give me the correct number of days in the preceeding 5 years?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想你想要这个:
I think you want this:
这将正确解释闰年。现在执行此操作可获得 1,826 天。
This will correctly account for leap years. Doing this right now yields 1,826 days.