CONVERT date with century

  • I am using the CONVERT function to format a date with the century. My code is like this:

    CONVERT(VARCHAR(8), mydate, 112)

    where mydate is a datetime datafield in a table.

    The problem I am having is that I cannot seem to control the century threshold that is returned. For example, if my input date has a value of 3/1/29, it is returning a value of 20290301 and not 19290301 as I would expect. If I convert a date like 12/25/50, it converts it properly to 19501225.

    I have looked to see if there was some kind of setting that would control the threshold of when the century is set to last one or uses the current. I know many software have the ability to control that threshold. Is there one in SQL 2005?

  • Check this one:

    http://www.blackwasp.co.uk/SQLDateTimeCutOff.aspx

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • Thanks... It's just what I needed.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply