Home > Archive > Microsoft SQL Server forum > August 2005 > Datediff needs to deliver month AND days









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Datediff needs to deliver month AND days
thrilled

2005-08-26, 8:23 pm

with datediff all I can get it to return is months or a total of the
days...

so if the difference in dates is 12 months 4 days how do I adjust the
SQL to accommodate both?

DA Morgan

2005-08-26, 8:23 pm

thrilled wrote:
> with datediff all I can get it to return is months or a total of the
> days...
>
> so if the difference in dates is 12 months 4 days how do I adjust the
> SQL to accommodate both?


So in February/March you want to return 1 month 2 days some years
and 1 month 1 day every fourth?

You'll need to write it yourself.
--
Daniel A. Morgan
http://www.psoug.org
damorgan@x.washington.edu
(replace x with u to respond)
thrilled

2005-08-26, 8:23 pm

you're the best

Erland Sommarskog

2005-08-26, 8:24 pm

thrilled (decramer@cox.net) writes:
> with datediff all I can get it to return is months or a total of the
> days...
>
> so if the difference in dates is 12 months 4 days how do I adjust the
> SQL to accommodate both?


As DA Morgan pointed out, the question needs further clarification.
For instance, how many months + days are there from 2005-08-27 to
2005-04-03? From 2004-02-27 to 2005-09-03?



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com