'timestampadd' is not a recognized built-i

2019-08-07 04:51发布

问题:

I'm trying to convert a 6 digit date into a regular looking date.

Currently we have this in the DB:

734562
734776
734837

Here's what I am trying:

select 



                    timestampadd(
                                    sql_tsi_day
                                    ,rbaging.billing_period_end
                                    ,cast('0001-01-01' as sql_timestamp)
                                )
                    -1,*


 from 

[kslap208].[c021]..RB_Resident_Aging  rbaging

the error i'm getting is:

Msg 195, Level 15, State 10, Line 5
'timestampadd' is not a recognized built-in function name.

how do i convert this field into a regular date field?

回答1:

If the remote source is an integer, or can be cast to one, I believe this should do it:

 SELECT DATEADD(DD, Field - 730000, '2001-01-01')