Hi Everybody,
I have a column Fecha_Apertura int(4) that content data as 1157472771, and I need convert this to datetime.
Someone know of any script?
Thanks by your help
Do you know the format of the datetime value? How is it actually stored? Is it days from some fixed date? Or is it seconds and so on. What is the precision of the value? If we know the storage format then it is easy to write some series of expressions to convert it to datetime/smalldatetime.|||This is probably "Unix time," or seconds after January 1, 1970.
To convert it, use DATEADD:
select dateadd(second,1157472771,'19700101')
This may be off by 22 seconds or so, because Unix time is supposed
to take leap seconds into account, something that SQL Server's dateadd
function does not do. If you can live with that bit of error, don't
worry about it. Otherwise, you'll have to find out the details of the
leap seconds and whether your values do account for them.
Steve Kass
Drew University
http://www.stevekass.com
Lisset@.discussions.microsoft.com wrote:
> Hi Everybody,
>
> I have a column Fecha_Apertura int(4) that content data as 1157472771,
> and I need convert this to datetime.
>
> Someone know of any script?
>
> Thanks by your help
>
>
>
>
>
>
No comments:
Post a Comment