Unix Technical Forum

Convert INT YYYYMMDD to date mm/dd/yyyy

This is a discussion on Convert INT YYYYMMDD to date mm/dd/yyyy within the SQL Server forums, part of the Microsoft SQL Server category; --> I can't seem to find a way to convert an INT type in the form of YYYYMMDD to an ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 03:40 PM
rdraider
 
Posts: n/a
Default 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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 03:40 PM
=?iso-8859-1?q?C=E9dric_Del_Nibbio?=
 
Posts: n/a
Default Re: Convert INT YYYYMMDD to date mm/dd/yyyy

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.net> wrote:
> 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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:41 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com