Results 1 to 6 of 6

Thread: date format

  1. #1
    Join Date
    Apr 2003
    Posts
    11

    date format

    When you put data int a MS SQL database via php, dependign on the SQL Server version you are using, the date format needs to be different. Eg a German Server wouldn't accept something like yyyy.mm.dd, but dd.mm.yyyy would work fine here. But dd.mm.yyyy isn't working on an English version of an MS SQL Server. I wonder if there is one format, that EVERY MS SQL Server understands?

    Michael

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You can use SET DATEFORMAT to set the date format you want.

    Or did you try using alphabetic date format like

    12 Apr 2003

  3. #3
    Join Date
    Apr 2003
    Posts
    11
    Originally posted by skhanal
    You can use SET DATEFORMAT to set the date format you want.
    I'm not quite sure how, or better where to issue this command? I have a php script, where I "execute" a stored procedure...

    Michael

  4. #4
    Join Date
    Nov 2002
    Location
    DE
    Posts
    246
    You can look up the usage of SET dateformat in BOL.

    Using the string format e.g. '1 Apr 2003' is significant but causes problems with different spelling. A german server will not understand '1 Oct 2003' it expects '1 Okt 2003'

    Wht about offering three drop-downs for the date input:
    1) Days 1..31
    2) Months 1..12
    3) Years 2003..2010

    You can then check if it is a valid date wehn concatening the dateparts. If valid send it as YYYYMMDD to the server and use SET DATEFORMAT ymd to make sure SQL server undersands the format well.

  5. #5
    Join Date
    Apr 2003
    Posts
    11
    Originally posted by andi_g69
    You can look up the usage of SET dateformat in BOL.
    Sorry for the stupid question, but what is BOL and were can I find it ?

    Originally posted by andi_g69

    You can then check if it is a valid date wehn concatening the dateparts. If valid send it as YYYYMMDD to the server and use SET DATEFORMAT ymd to make sure SQL server undersands the format well.
    Thanks for the tipp, I'll try it, as soon as I find something about that SET command...

    Michael

  6. #6
    Join Date
    Nov 2002
    Location
    DE
    Posts
    246
    BOL = BooksOnLine

    You can find them on your DB server under Programs/MS SQL Server/ Books Online

Posting Permissions

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