I am working with an AS400 database and SQLServer 2008. I would like a way to convert a date in say, MM-DD-YYYY into lilian format and back in T-SQL. Anyone know of any? Even if I convert the data that I had in the AS400 into SQLServer 2008 I believe I will still need the same function.
From stackoverflow
-
I don't think there's a built in function. Could you just use the datediff function to convert to a lilian date format? Something like this:
declare @testDate DateTime; set @testDate = '2009-01-01'; declare @lilianDate int; -- the datediff statement will do the conversion set @lilianDate = DATEDIFF(day, '1582-10-14', @testDate); print @lilianDateand to get back you can use a dateadd() function in a similar way I would think.
You could make UDFs to wrap this functionality if you are going to need it in several places.
0 comments:
Post a Comment