Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subtracting Dates 1

Status
Not open for further replies.

tseh

Programmer
Jan 13, 2000
64
CA
Is there a way to subtract one date from the other in the select statemtent to get the difference in number of days?
 
select (day(datecolumn1)-day(datecolumn2)) as daydifference, other_things from sometable John Fill
 
This returns the number of days...but how do I get the months in days as well? Example, 04/30/01 - 02/28/01 returns 2. How do I get it to return 61 days?
 
Use the DateDiff function with the 'd' parameter. Robert Bradley
teaser.jpg

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top