Results 1 to 12 of 12
  1. #1
    Join Date
    Feb 2004
    Location
    El Salvador
    Posts
    46

    Question Unanswered: datetime format problem

    Is there any standard function for inserting datetime values to an sql table. I'm having a problem because some operating systems are in english and some operating systemes are in spanish.. When I insert a value '2005-02-15 12:00:00' it works on the english operating system, but it doesn't in the spanish one... any ideas?

  2. #2
    Join Date
    Dec 2004
    Location
    CA, USA
    Posts
    63
    try GETDATE ( )

  3. #3
    Join Date
    Feb 2004
    Location
    El Salvador
    Posts
    46
    I am getting the date/time from a date time picker in visual basic.. it's not the current date.

  4. #4
    Join Date
    Jan 2005
    Location
    TempDb
    Posts
    228
    Define date time picker. Sounds like you need one or more of the following:
    1. A smarter date time picker that converts all datetimes to a standard format.
    2. To write a routine that adds intelligence to your picker.
    3. Some VB function that does b. for you. The lack of strong-typing in VB may make this very difficult.

    SQL Server has this interesting trait of trying to do exactly what you ask it to do. You may also want to read up on Cast/Convert in SQL BOL.
    I love deadlines. I like the whooshing sound they make as they fly by. Douglas Adams

  5. #5
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    ?????

    If it is a VB control I would think it would be returning a VB datetime value, which is just a number with no formatting applied.

    But if you are converting this to a string and submitting it to SQL Server as a datetime value (which you shouldn't be doing), then this format should be universally recognized by SQL Server:

    yyyy-mm-dd hh:mi:ss

    ...where hh uses a 24 hour clock.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  6. #6
    Join Date
    Jan 2005
    Location
    TempDb
    Posts
    228
    If it is a VB control I would think it would be returning a VB datetime value, which is just a number with no formatting applied.
    Excellent point. So, diegocro, why is the value being sent a text string?
    I love deadlines. I like the whooshing sound they make as they fly by. Douglas Adams

  7. #7
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Am I missing something (very possible)? How else can you send a date value from VB to SQL?
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  8. #8
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Unlikely. You don't miss much.

    But the VB code could be converting or storing the data in any number of odd ways before it is submitted to SQL Server. A lot can happen to data at point B while it is traveling from point A to point C...
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  9. #9
    Join Date
    Feb 2005
    Posts
    78
    Or you could try CAST or CONVERT to change the text string to a DATE format.

    e.g. CONVERT(datetime,'2005-02-15 12:00:00' ,120) (see BOL for more detail)

  10. #10
    Join Date
    Feb 2005
    Posts
    1
    you can do something like this
    Code:
    convert(datetime,datepickervalue,101)

  11. #11
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    [sniped]
    [sniped]
    [sniped]
    [sniped]
    [sniped]
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  12. #12
    Join Date
    Feb 2004
    Location
    El Salvador
    Posts
    46
    ok
    CONVERT(datetime,'2005-02-15 12:00:00' ,120) works, thanks a lot.

Posting Permissions

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