467,179 Members | 1,419 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,179 developers. It's quick & easy.

Convert INT YYYYMMDD to date mm/dd/yyyy

I can't seem to find a way to convert an INT type in the form of YYYYMMDD to
an actual date form of mm/dd/yyyy

Can anyone pointt me in the right direction?

Thanks
Aug 23 '07 #1
  • viewed: 68174
Share:
1 Reply
Hi there,

The easiest way to achieve your goal is to convert your INT into an
eight character long string first, and then convert your string in the
datetime format.
As an example : SELECT CONVERT(DATETIME, CONVERT(CHAR(8), 20070824))

Elsewhere, it is a bit complicated, as the DateTime format is based on
the difference in days from 1900/01/01. Thus, you have to use a quite
heavy function as leap years are not regular. All the functions I
tried have bad performance compared to the double conversion.

Enjoy,

Cédric Del Nibbio
MCT
MCDBA SQL Server 2000
MCITP Database Administrator SQL Server 2005
MCSD .NET
http://cedric-delnibbio-sql.blogspot.com

On 24 août, 00:41, "rdraider" <rdrai...@sbcglobal.netwrote:
I can't seem to find a way to convert an INT type in the form of YYYYMMDDto
an actual date form of mm/dd/yyyy

Can anyone pointt me in the right direction?

Thanks
Aug 24 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Sam | last post: by
4 posts views Thread by Daniel Kaseman | last post: by
4 posts views Thread by Ashraf Ansari | last post: by
4 posts views Thread by Lagon666 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.