Results 1 to 7 of 7
  1. #1
    Praveenevg is offline Novice
    Windows 8 Access 2007
    Join Date
    Aug 2014
    Posts
    18

    Concatenate Date and Time values into a Date field

    Hello,



    I have two date variables VAR_DATE and VAR_TIME

    VAR_TIME has time in HH:MM:SS AM/PM format. VAR_TIME = 09:35:40 AM

    VAR_DATE has date and time; VAR_DATE = 10/21/2014 12:00:00 PM

    How can i change the VAR_DATE to 10/21/2014 09:35:40 AM?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    How about using DateValue() on the second and add the result to the first?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    By the way, I deleted your duplicate thread. Please don't post the same question twice.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Praveenevg is offline Novice
    Windows 8 Access 2007
    Join Date
    Aug 2014
    Posts
    18
    Thanks. Would you be able to give me some sample code please?

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,643
    Are both variables declared as date type?

    Try:

    Format(VAR_DATE, "mm/dd/yyyy") & " " & VAR_TIME
    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.

  6. #6
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    If both variables are defined as Date you can simply add them together using the + operator.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,643
    Yes, except the time component shown is 12:00:00 PM (noon). Result of adding gives a date/time 12 hours off:

    10/21/2014 9:35:40 PM

    If OP really meant to show midnight time then the addition will work because Access/VBA considers midnight as 0 time.
    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.

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

Similar Threads

  1. Replies: 11
    Last Post: 07-20-2014, 06:22 PM
  2. Subtracting a date/time field from a number to get date/time
    By Lifeseeker1019 in forum Programming
    Replies: 4
    Last Post: 03-28-2014, 12:59 PM
  3. Replies: 4
    Last Post: 09-27-2013, 02:21 AM
  4. Replies: 15
    Last Post: 04-06-2012, 10:57 AM
  5. Getting Just the Date part of Date/Time field
    By GaryElwood in forum Reports
    Replies: 7
    Last Post: 09-28-2011, 09:58 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