Results 1 to 15 of 15

Thread: [RESOLVED] SQL Date Issue

Hybrid View

  1. #1

    Thread Starter
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Resolved [RESOLVED] SQL Date Issue

    Im having an issue when inserting a date into my sql server table.

    the table's date column is set to smalldatetime

    so when i try to insert the date 23/03/2005 into the column, when i look on sql server the field contains 01/01/1900

    however if i insert 03/23/2005, when i look on sql server the field contains 23/03/2005

    why is this happening..... my regional settings are set to GMT.
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  2. #2
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668

    Re: SQL Date Issue

    There's nothing wrong, thats just the way SQL stores dates.
    If wishes were fishes we'd all cast nets.

  3. #3

    Thread Starter
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: SQL Date Issue

    but why is it requiring me to insert the date in american format.

    why cant i insert as the european format

    when i insert as european date it gives me an error as it recognises that the 23 is not a month
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SQL Date Issue

    Quote Originally Posted by Strider
    but why is it requiring me to insert the date in american format.

    why cant i insert as the european format

    when i insert as european date it gives me an error as it recognises that the 23 is not a month
    SQL Server is very date biased to the American format.

    We always use YYYY-MM-DD when doing date INSERT's - so that ambiguity does not become a problem.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5

    Thread Starter
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: SQL Date Issue

    to make things all the more strange.......

    my application was working fine for the past two weeks then suddenly in the past few days its wont allow me to insert a date.now() into the date field....

    i get the error i previously mentioned....


    however, however...... when u insert date.today() it sets the date in the field to the 01/01/1900 ...and that aint the right date....

    what the hell is going on.
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SQL Date Issue

    Quote Originally Posted by Strider
    to make things all the more strange.......

    my application was working fine for the past two weeks then suddenly in the past few days its wont allow me to insert a date.now() into the date field....

    i get the error i previously mentioned....


    however, however...... when u insert date.today() it sets the date in the field to the 01/01/1900 ...and that aint the right date....

    what the hell is going on.
    01/01/1900 is a "blank" date getting inserted into the date field.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width