Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert INT to DATE in MS SQL Server?

Status
Not open for further replies.

beckwiga

Programmer
Mar 30, 2005
70
0
0
I'm trying to convert a date stored as an INT into a DATETIME format. For example, my date is formatted as 20071231 and I want to convert it to a proper DATETIME or SMALLDATETIME. Anyone know how would I go about doing this?

I searched the forum and Google'ed this, but have not had much luck. Any suggestions are much appreciated.
 
Denis nailed it (as expected) and FYI the reason this was so easy is that yyyymmdd as in '20071231' is one of the few formats that will always convert to a date properly, no matter what the datefirst/localization settings are.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top