Dates & Years

  • Hi all,

     Someone please help on the date problem. Does sql server allow the date 01-JAN-0997 to be stored in a table. Is there a way to store this date?

    Thanks & Rgds,

    Mallik

  • You can find out by using the following statement:

    select cast('01-JAN-0997' as datetime)

     

  • Hi Paul,

      Thanks for the response. But that would throw an out of range error as sql server would not allow dates prior to 01-01- 1753. Just wanted to know if there is any way to by pass this in case any settings are there to configure.

     

    Rgds,

    Mallik

  • I'm going to post the incredibly helpful :/ note that I saw this done once, using something similar to codepages for characters. Essentially, you could tell SQL Server to use a date other than 1900 to add and subtract from. But, I can't find it at this point, and I don't remember what the trick was.

    However, based on conversations I had several years ago regarding storing partial dates (for a historical timeline project, in which you might only know the month and year, not the day), your best bet is to store such dates as three separate integer columns. It's very friendly to sorting the dates, but very unfriendly to doing date calculations, unfortunately. A trick we worked out there was to convert the two dates we wanted to do a calculations on to a sort of "base 1900" format, and use the standard date functions.

  • Thanks Marshall, I would be eagerly waiting for your post.

    Rgds,

    Mallik

Viewing 5 posts - 1 through 4 (of 4 total)

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