I have a julian date(04159) and I need to convert this to any normal date format yyyymmdd or mmddyy or basically anything that I can work with! I am just about fed up with trying to convert this. It would be simple enough if there want leap years. Does anyone have a function or something out there that can convert this for me? Code that I found on the web turned out to be bogus. Your help will be greatly appreciated. If you have something in VB that would work also. SQLServer preferably.
ThanksIt may be off by a day or so, but it's a start:
select dateadd(day, cast(reverse(cast(reverse('04159') as char(3))) as int), '01/01/' + cast('04159' as char(2)))|||Yeah...Thats sorta where I left off in my efforts. Thanks for your input. I will eventually get it...Hopefully someone in here will see this and have something.|||This is ancient old code, from when SQL 2000 was still in beta, but I think it works. Give this a try:CREATE FUNCTION dbo.f_jDate(@.piJdate INT) RETURNS DATETIME AS
BEGIN
RETURN DateAdd(day, (@.piJdate % 1000) - 1, Convert(DATETIME
, CASE WHEN @.piJdate < 50000 THEN '20' ELSE '19' END
+ Replace(Str(@.piJdate / 1000, 2), ' ', '0') + '-01-01'))
END-PatP|||Thanks Pat....That worked perfectly! Your my hero for the day!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment