Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Location
    BA, Argentina
    Posts
    39

    Unanswered: Date and Time independently from local settings (SQL)

    Hi, i want to make a sql statement to insert a record into an access table. The table has a date/time field.
    Suppose I want to insert the date April 10 from year 1998 at hour 20:15... how would be the sql statmente, INDEPENDENTLY on my local configuration?... i have my configuration in DD/MM/YYYY, so it would be:

    INSERT INTO TABLE (...) VALUES (#10/4/1998 20:15#, ...)

    But, if the regional settings establish that dates are in format MM/DD/YYYY, the insert will be wrong...

    I tried to use DateSerial(1998,4,10), but the problem is that it does not take any time information, so, im looking for a function or a statement that creates a date expression with no format confusion...
    Thanks in advance

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you are halfway there.

    use dateserial to get to the date
    then dateadd to add hours
    then dateadd to add minutes etc etc
    then, since access dates are doubles, INSERT INTO... the number not the #blah#

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Oct 2003
    Location
    BA, Argentina
    Posts
    39
    Good idea, thanks

Posting Permissions

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