在SQL中保留天数,asp.net [英] Remainig days in sql, asp.net

查看:90
本文介绍了在SQL中保留天数,asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,每天有什么方法可以计算剩余天数吗?在表格中具有最终日期和开始日期的应用程序将是当前日期.在同一表中,有一个名为每天要更新的剩余天数"的字段,另一种选择是一个函数,该函数每天将向该字段减去一个值以达到0.有什么建议吗?对于如何去那里寻求帮助,我也有相同的想法.

Hello, is there some way every day to calculate the remaining days? Where the application with the final date in a table and start date would be the current date. In the same table have a field called Remaining days to be updated every day, another alternative would be a function that every day would subtract a value to this field to get to 0. Any suggestions? I have the same ideas of how to be there asking for your help.

推荐答案

您可以尝试 CP文章&质量检查 [ ^ ].
You can try DATEDIFF (Transact-SQL)[^] which returns the count (signed integer) of the specified datepart boundaries crossed between the specified startdate and enddate.

Also have look on some CP Articles & QA[^] on same.


在SQL中,使用datediff(dd, getdate(), [last_date_column]).您可以将其添加到查询中,而无需将其添加到表中.您可以在where子句中过滤负数,或使用CASE将它们替换为零.
希望这会有所帮助,
巴勃罗.
In SQL, use datediff(dd, getdate(), [last_date_column]). You can add it to your query, you don''t need to add it to the table. You can filter negative numbers in the where clause, or replace them by zero using CASE.
Hope this helps,
Pablo.


这篇关于在SQL中保留天数,asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆