Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2003
    Posts
    100

    Question Unanswered: Probably, a very simple date convertion.

    Hi I'm attempting to enter a date into a datetime field and I can't work out how to get the insert command to understand the format of the date that is given to me in is.

    this is the SQL that isn't working:

    INSERT INTO TRANSACTIONS (ActionDate)
    VALUES ('28/07/2003 14:22:28')

    My eternal gratatued for any help!

    P.S. I don't know if it important but it's from ASP into a SQL Server db.

  2. #2
    Join Date
    Feb 2003
    Location
    Milano, Italy
    Posts
    80
    You can set the date using the

    SET DATEFORMAT xxx

    option

    Anyway i have to things two say that may help you:

    1)
    If you have to insert the current date use the GETDATE() function.
    Eg:
    INSERT INTO TRANSACTIONS (ActionDate)
    VALUES (GETDATE())

    2) If should insert the date in the standard ISO format:

    yyyymmdd

    so they are used as they are specified and thus not treated using the region-dependant format.
    Eg:
    INSERT INTO TRANSACTIONS (ActionDate)
    VALUES ('20030728 14:22:28')
    Davide Mauri
    http://www.davidemauri.it

Posting Permissions

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