简体   繁体   中英

How do I find the difference between two dates in one query?

i have a table in Mssql, in that table i have two columns that keeps different dates. (both data types are smalldatetime) my aim is , if difference is equal 60 days or bigger than 60 days then i want to bind this values into a grid view. How can i get this values in single sql query? Thanks for your help.

Not a lot of information, so best guess looks like this:

SELECT DATEDIFF(day, date1, date2) Difference, date1, date2
FROM aSecretTable
WHERE DATEDIFF(day, date1, date2) >= 60

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM