[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1042
  • Last Modified:

Convert int column into datetime

all date columns in this db are defined as int and look weird. normally i would expect 8 digits (for YYYYMMDD) something like 20080131
but these have 10 digits and look weird. if i run
select top 10 myDateColumn from myTable order by myDateColumn desc  
it returns like:
1201820136
1201820052
1201820051
etc

could you show me how to extract a proper datetime from this?
0
iamari
Asked:
iamari
1 Solution
 
Chris MangusDatabase AdministratorCommented:
It's seconds after 1/1/1970.

Try:

Select Top 10 DateAdd(ss, myDateColumn, '1/1/1970')
From myTable
Order by myDateColumn Desc
0
 
iamariAuthor Commented:
geez, thanks a lot cmangus, works just fine!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now