May 2, 2011 at 9:12 am
Hello,
Can some please tell me how to convert todays date to julian format
Thank you
May 2, 2011 at 9:24 am
ahh...but WHICH Julian format do you want?
from lurking here on the forums, I've seem three different styles;
for example
109252 = in AS400/DB2 date is 01/01/1900 + 109 years + 252 days
1997090101636 = 4 year Century + 090 julian days days + 10 hours + 16 minutes + 36 seconds
199709014399 = 4 year Century + 090 julian days days + 14399 seconds
Lowell
May 2, 2011 at 9:34 am
The data is going to JDEdwards
May 2, 2011 at 9:41 am
These scripts appear to work correctly, but do not return a time value.
http://www.sqlservercentral.com/scripts/Miscellaneous/31225/
May 2, 2011 at 9:56 am
Krasavita (5/2/2011)
The data is going to JDEdwards
I think you'll have to check with them to know what specific format they expect before we can give you much of a code example.
Lowell
May 2, 2011 at 2:20 pm
here's an example on how to get all the elements to create the Julian date; to append them you have to cast them to VARCHAR, and you'd also have to take into consideration whether you need preceding zeros and stuff (SELECT RIGHT('000' + SomeValue,3)
select [Years] = datediff(year,0,ET),
[Months] = datepart(month,ET-ST)-1,
[Days] = datepart(day,ET-ST)-1,
[JulianDays] = datediff(day,ST,ET),
[Hours] = datepart(Hour,ET-ST),
[Minutes] = datepart(Minute,ET-ST),
[Seconds] = datepart(Second,ET-ST),
[Milliseconds] = datepart(millisecond,ET-ST)
from
(
select -- Test Data
ST = DATEADD(yy, DATEDIFF(yy,0,getdate()), 0),
ET = getdate()
) a
Lowell
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply