sql - How can I change number of days to date? -
how can alter number of days date in sql server 2008 ?
sample days :730677
. output : 2000-07-11
.
you have problem,
the earliest date represented sql sever datetime2
'0001-01-01'
as can see 366 days after "epoch start"
select 730677 - datediff( day, cast('0001-01-01' datetime2), cast('2000-07-11' datetime2));
to perform calculation like
declare @days int = 730677; select dateadd(day, @days - 366, cast('0001-01-01' datetime2));
if need represent days before 366, need alternative.
sql sql-server sql-server-2008 date
No comments:
Post a Comment