SQL-ASP.NET datetime format problem ???

Discussion in 'ASP .Net' started by Ugur Ekinci, Dec 16, 2005.

  1. Ugur Ekinci

    Ugur Ekinci Guest

    Hi ,
    I have two Sql Server 2000 on seperate machines ,
    First one accepts datetime format like ("dd.MM.yyyy hh:mm:ss")
    And Second one accepts datetime format like ("MM.dd.yyyy hh:mm:ss")

    1- Date formats are different because of SQL Collation?
    2- Do regional Settings affect Sql date format?
    3- (Important) When inserting a datetime into first server there is no
    problem (15.12.2000 12:12:12) , but when I insert into second server (if day
    is greater then 12 ) the following error occurs
    "The conversion of a char data type to a datetime data type resulted in an
    out-of-range datetime value"


    So each time I format the datetime value to ("dd.MM.yyyy hh:mm:ss") when
    inserting into second server,

    I don't want to change date Format each time manuelly
    So I think ,I need to know that in code behind Which date format SQL server
    accept?
    My app is ASP.NET with VB.NET

    I use System.DateTime , should I use System.Data.SqlTypes.SqlDateTime ?
    Any idea ?

    Best regards...
     
    Ugur Ekinci, Dec 16, 2005
    #1
    1. Advertisements

  2. Always format dates to include the month as a NAME it makes some many
    problems like this go away!

    eg "dd MMM yyyy hh.mm.ss" or "MMM dd yyyy hh.mm.ss"

    sql server( and most other databases) then has enough to go on when in
    converts the string to a datetime.

    i assume you are building the sql string in code, if you use dataadapters
    and parameters then dot net will do the culture stuff for you.


    "Ugur Ekinci" <> wrote in message
    news:%...
    > Hi ,
    > I have two Sql Server 2000 on seperate machines ,
    > First one accepts datetime format like ("dd.MM.yyyy hh:mm:ss")
    > And Second one accepts datetime format like ("MM.dd.yyyy hh:mm:ss")
    >
    > 1- Date formats are different because of SQL Collation?
    > 2- Do regional Settings affect Sql date format?
    > 3- (Important) When inserting a datetime into first server there is no
    > problem (15.12.2000 12:12:12) , but when I insert into second server (if
    > day is greater then 12 ) the following error occurs
    > "The conversion of a char data type to a datetime data type resulted in an
    > out-of-range datetime value"
    >
    >
    > So each time I format the datetime value to ("dd.MM.yyyy hh:mm:ss") when
    > inserting into second server,
    >
    > I don't want to change date Format each time manuelly
    > So I think ,I need to know that in code behind Which date format SQL
    > server accept?
    > My app is ASP.NET with VB.NET
    >
    > I use System.DateTime , should I use System.Data.SqlTypes.SqlDateTime ?
    > Any idea ?
    >
    > Best regards...
    >
    >
    >
    >
    >
    >
     
    AdrianJMartin, Dec 16, 2005
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    1,047
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. mp
    Replies:
    1
    Views:
    679
    John Machin
    Jul 28, 2006
  3. Steve Kershaw
    Replies:
    0
    Views:
    10,973
    Steve Kershaw
    Aug 26, 2006
  4. Steve Kershaw
    Replies:
    5
    Views:
    6,186
    Steve Kershaw
    Aug 29, 2006
  5. Martin
    Replies:
    0
    Views:
    643
    Martin
    Dec 27, 2008
  6. Replies:
    2
    Views:
    1,063
    M.-A. Lemburg
    Jan 6, 2009
  7. NiklasRTZ

    datetime.datetime. or datetime. ?

    NiklasRTZ, Oct 8, 2009, in forum: Python
    Replies:
    10
    Views:
    758
    niklasr
    Oct 11, 2009
  8. Ludovic DE FREITAS

    ASP.Net 2 Two Way Binding and DateTime Format Problem

    Ludovic DE FREITAS, Jan 9, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    1,928
    Phillip Williams
    Jan 9, 2006
Loading...