Showing posts with label feb. Show all posts
Showing posts with label feb. Show all posts

Sunday, March 25, 2012

Day of year

How would I get the day of year from a datetime field in a query?
Such as Feb. 28 would be day 59.
Thank youSELECT DATEPART(DAYOFYEAR,'20050228') ;
David Portas
SQL Server MVP
--
"Lyners" <Lyners@.discussions.microsoft.com> wrote in message
news:78DFFDDD-9227-4A95-896E-F50FDCBB4E17@.microsoft.com...
> How would I get the day of year from a datetime field in a query?
> Such as Feb. 28 would be day 59.
> Thank you

Tuesday, February 14, 2012

Dateadd problem

Try this:

print dateadd(y,+4, '29 feb 2008')

Funny how the 1 day that is used to go from 29 jan to 1 mar stack if you add multible years to a day.

+4 year should put it back on 29 feb 2012, +3 years should put it on 1 mar 2011.

Well, mabye it has been posted before, I just found it interesting.

That is because you are using y not yy. Look in the BOL for the parameters. dy/y is dayofyear not year.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de