Convert INT YYYYMMDD to date mm/dd/yyyy

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rdraider

    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


  • =?iso-8859-1?q?C=E9dric_Del_Nibbio?=

    #2
    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(DATETIM E, 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
    Allergiques aux produits de la firme de Redmond passez votre chemin.Architecture et développement avec SQL Server et .NET.


    On 24 août, 00:41, "rdraider" <rdrai...@sbcgl obal.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

    Comment

    Working...