Assuming it's 0 based, here's a walkthrough that includes the setup of sample data. You can run the whole thing to play around or just skip to the last statement to see the expression you need.------------------------------------------------------------------------------------ Get some numbers to play with, in this case, 64----------------------------------------------------------------------------------;WITH E1(N) AS(SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1),E2(N) AS (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) as N FROM E1 a, E1 b, E1 c)------------------------------------------------------------------------------------ Using 1-64, calculate a BIGINT from 0 (1/1/1900) to generate a starting dataset----------------------------------------------------------------------------------, cte_BIGINT_BDaysAS(select N,convert(bigint,dateadd(d,datediff(d,0,getdate())+N-1,0)) as BIGINT_BDayfrom E2)--SELECT * FROM cte_BIGINT_BDays/*---------------------------------------------------------------------------------- Results----------------------------------------------------------------------------------BIGINT_BDayN BIGINT_BDay1 415052 41506... other entries ...63 4156764 41568(64 row(s) affected)--*/ ----------------------------------------------------------------------------------------------------------------------------------------------------------------- Now show how to calculate the DATETIME and VARCHAR representations from the BIGINT----------------------------------------------------------------------------------SELECT N,DATEADD(d,BIGINT_BDay,0) as DATETIME_BDay,CONVERT(VARCHAR(10),DATEADD(d,BIGINT_BDay,0),101) AS VARCHAR_BDayFROM cte_BIGINT_BDays/*--------------------------------------------------------------------- Results---------------------------------------------------------------------N DATETIME_BDay VARCHAR_BDay1 2013-08-21 00:00:00.000 08/21/20132 2013-08-22 00:00:00.000 08/22/2013... other entries ...63 2013-10-22 00:00:00.000 10/22/201364 2013-10-23 00:00:00.000 10/23/2013(64 row(s) affected)--*/ ----------------------------------------------------------------
Please note that you will have to determine what the BIGINT is based on.* Edit: Added more comments and cleaned up formating