Tuesday, May 17, 2011

JD Edwards -Julian to Calendar vise versa Date Conversion- SQL function

 

CREATE FUNCTION [dbo].[JDT_GTJ] (@DATE datetime)

RETURNS varchar(12)

 

AS

BEGIN

        declare @y as varchar(10)

        declare @dy as varchar(10)       

        declare @date1 as datetime       

        declare @szupmj as varchar(10)

if(@DATE='')

Begin

     set @date1= getdate()

End

if(@DATE<>'')

Begin

        set @date1= @DATE

End

 

set @y =(datepart(yy,@date1) - 1900) * 1000;

set @dy = datepart(dy,@date1);

set @szupmj = @y + cast(@dy as int);

     RETURN(@szupmj);

END;

 

 

 

CREATE FUNCTION [dbo].[JDT_JTG] (@DATE int)

RETURNS varchar(20)

 

AS

BEGIN

declare @rpdivj as int

declare @datea as datetime

declare @szupmj as varchar(10)

set @rpdivj=@DATE

set @datea= DATEADD(dy, @rpdivj % 1000, DATEADD(yy, @rpdivj / 1000,-1))

set @szupmj=convert(varchar,@datea,101) --DATEADD(dy, @rpdivj % 1000, DATEADD(yy, @rpdivj / 1000, -1))

 

     RETURN(@szupmj);

END;

 

 

No comments: