Results 1 to 4 of 4

Calculating date

  1. #1
    terry6582 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2017
    Location
    TN
    Posts
    21

    Calculating date


    Have a DB with the following fields.

    Reg_Date....The date a attendee registers.
    Adult............the number of days the adult will attendee.
    other............The number of days other will attendee
    early_bird....The number of days the attendee will use early bird.

    I need to calculate the number of days prior to the reg_date the adult, other or early_bird will be attending and subtract from the reg_date.

    reg_date - adult + other+ early_bird. then display the date the attendee is estimated to arrive.

    help please!

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,240
    I believe you would use DateAdd. Even though it says Add, you can subtract a number of days or other intervals with the function by using negative numbers in the 2nd argument.

    TotalDaysToSubtract = (Adult + Other + early_bird) * -1

    ArriveDate = DateAdd("d", TotalDaysToSubtract, Reg_Date)

    might all work on same line

    ArriveDate = DateAdd("d", (Adult + Other + early_bird) * -1, Reg_Date)

    Look up Dateadd and DateDiff functions, they are used alot.

  3. #3
    Join Date
    Apr 2017
    Posts
    996
    As dates are really numbers, you can freely add/remove numbers to/from dates. I.e.
    Code:
    ArriveDate = (Reg_Date - Adult + Other + Early_Bird)

  4. #4
    terry6582 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2017
    Location
    TN
    Posts
    21
    Thatr worked for me

    Thanks

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

Similar Threads

  1. Replies: 3
    Last Post: 03-05-2019, 06:48 PM
  2. Replies: 15
    Last Post: 09-12-2018, 07:24 AM
  3. Replies: 1
    Last Post: 11-27-2017, 02:02 PM
  4. Replies: 1
    Last Post: 04-29-2016, 04:03 AM
  5. Calculating Qurter out of Date
    By dinesh_ltjd in forum Access
    Replies: 5
    Last Post: 02-22-2013, 07:07 PM

Posting Permissions

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