Christian Christiansen
July 28th, 2010, 02:31 PM
Hi,
I am trying to convert some functions from oracle, ms sql and db2 to mysql and I have reached a dead end. I need a function to convert Julian day to the Gregorian calender so 2455406 will be outputted as 2010-07-28 or 20100728.
Here is the code from the microsoft sql function:
drop function jdate2date
GO
CREATE FUNCTION jdate2date
(
@indate int
)
RETURNS datetime
AS
BEGIN
DECLARE @gregorian_date datetime
if @indate > 0
SET @gregorian_date = cast((@indate-2415021) as datetime)
else SET @gregorian_date = NULL
RETURN @gregorian_date
END
GO
I can post the code from db2 and oracle as well if necessary.
Thanks in advance.
I am trying to convert some functions from oracle, ms sql and db2 to mysql and I have reached a dead end. I need a function to convert Julian day to the Gregorian calender so 2455406 will be outputted as 2010-07-28 or 20100728.
Here is the code from the microsoft sql function:
drop function jdate2date
GO
CREATE FUNCTION jdate2date
(
@indate int
)
RETURNS datetime
AS
BEGIN
DECLARE @gregorian_date datetime
if @indate > 0
SET @gregorian_date = cast((@indate-2415021) as datetime)
else SET @gregorian_date = NULL
RETURN @gregorian_date
END
GO
I can post the code from db2 and oracle as well if necessary.
Thanks in advance.