November 18, 2003 at 6:21 am
I need my query to return today's date as a Julian, e.g. 2003322
What is the best way to do this?
November 18, 2003 at 6:24 am
SELECT YEAR(GETDATE())*1000+DATEPART(y,GETDATE())
--Jonathan
--Jonathan
November 18, 2003 at 7:05 am
Thank you.
November 18, 2003 at 8:08 am
http://dbforums.com/arch/68/2002/11/557659
might also be of interest
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 19, 2003 at 6:28 am
This statement will not work for dates that fall in the year 2000. Which is the best way to do for year 2000?
November 19, 2003 at 6:51 am
How about
cast(year(GETDATE()) as varchar) +
REPLACE(STR(DATEDIFF(d,cast(year(GETDATE()) as varchar)
+ '-01-01',GETDATE())+1,3),' ','0')
Far away is close at hand in the images of elsewhere.
Anon.
November 19, 2003 at 7:35 am
Thank you
November 19, 2003 at 7:42 am
quote:
This statement will not work for dates that fall in the year 2000. Which is the best way to do for year 2000?
The statement I posted certainly will; the YEAR() function returns four digits...
declare @d datetime
set @d = '2000-02-15'
SELECT YEAR(@d)*1000+DATEPART(y,@d) -- Returns 2000046
--Jonathan
--Jonathan
November 19, 2003 at 6:23 pm
select datediff(dd, '12-31-' + cast(datepart(yy, getdate())-1 as varchar), getdate())
Signature is NULL
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply