--Normal Date to Julian Date
declare @rpdivj as int
declare @datea as datetime
set @rpdivj='102015'
set @datea= DATEADD(dy, @rpdivj % 1000, DATEADD(yy, @rpdivj / 1000,-1))
print DATEADD(dy, @rpdivj % 1000, DATEADD(yy, @rpdivj / 1000, -1))
print DATEPART(month, @datea)
print DATEPART(day, @datea)
print DATEPART(year, @datea)
--Julian Date to Normal Date
declare @y as varchar(10)
declare @dy as varchar(10)
declare @date1 as datetime
declare @szupmj as varchar(10)
set @date1= getdate()--'10/01/02'
-- set @date1= '10/1/2002'
set @y =(datepart(yy,@date1) - 1900) * 1000;
set @dy = datepart(dy,@date1);
set @szupmj = @y + cast(@dy as int);
print 'Date ====>>> '+ @szupmj
in Select Statement
DATEADD(dy, cast(SDTRDJ as varchar(10)) % 1000, DATEADD(yy, cast(SDTRDJ as varchar(10)) / 1000,-1))
select (datepart(yy,getdate()) - 1900) * 1000+ cast(datepart(dy,getdate())as int)
select CONVERT(CHAR(15),GETDATE(),101)
No comments:
Post a Comment