Results 1 to 3 of 3
  1. #1
    samsquared is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    May 2021
    Location
    St. Augustine, FL
    Posts
    20

    Problems with SQL update containing date field

    I've Googled for the answer to this but haven't found the right right way to use the # sign for a date field. I have the following SQL update statement:

    strSQL = "update tblStocks set tblStocks.[Next Ex-Dividend] = " & dtExDivDate & " Where tblStocks.Symbol = " & "'" & strSymbol & "'"

    dtExDivDate is declared as Date field. This creates the following SQL string:

    "update tblStocks set tblStocks.[Next Ex-Dividend] = 10/8/2021 Where tblStocks.Symbol = 'T'"

    This runs but the resulting value inserted into [Next Ex-Dividend] (defined as short date) is 12/30/1899



    What do I need to do with this date field to get it to update correctly? I always seem to have a problem with date fields...

    Thanks.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    = #" & dtExDivDate & "# Where
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    samsquared is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    May 2021
    Location
    St. Augustine, FL
    Posts
    20
    That worked - thank you for the quick reply!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Record Update Date field
    By tfbalogh in forum Access
    Replies: 5
    Last Post: 01-31-2017, 09:30 AM
  2. Update Field based on Max Date
    By janmack79 in forum Queries
    Replies: 27
    Last Post: 01-18-2017, 01:07 PM
  3. VBA Update Statement to update Date field
    By zephyr223 in forum Programming
    Replies: 6
    Last Post: 10-27-2016, 10:45 AM
  4. Update date field
    By Loucorea in forum Access
    Replies: 4
    Last Post: 09-26-2012, 08:22 PM
  5. Extra date field update
    By georgft in forum Forms
    Replies: 0
    Last Post: 09-17-2008, 06:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums