Results 1 to 9 of 9
  1. #1
    hazeleyre23 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    34

    How to Add 2, 5 or 30 working days to a date

    Hi,



    I have a date field (Date Entered) which is manually entered in Access, however I have another date field (Date Chased) in which I want this field to automatically populate with +2 working days from Date Entered.

    I have a few other fields which I want to add +5 working days and another to i want to be able to +30 working days. However I assume once I have the code I will be able to adjust it.

    Thank You

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    use the dateadd function or just

    [Date Entered]+2

    how to use it? if Date Chased is unbound put

    =[Date Entered]+2

    in the control source

    if it is bound, put

    [Date Chased]=[Date Entered]+2

    in the Date Entered afterupdate event

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    DATEADD("D",2,[datefield])

  4. #4
    hazeleyre23 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    34
    Thank you both for your help, that works great but is there anyway I can get it to count working days only so Monday - Friday.

    thanks

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    to be clear - by count working days you mean if today is Thursday, you don't want Saturday, you want Monday to be the result of the calculation?

    If so you need a UDF. There are many examples out there, here is one

    https://social.msdn.microsoft.com/Fo...3?forum=isvvba

    in this example, if you are not bothered about bank holidays, remove the if part of the dcount line (and you won't need the holiday table), you just need to retain I=I+1

  6. #6
    hazeleyre23 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    34
    Yes that is correct, I want to not count Saturday and Sunday.

    How do I then get the field I want to automatically update to refer to this code.

    I am fairly new to Access so apologies.

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    OK - so look at the example provided. It will need to go into a general module (i.e. not one which is specific to a form)

  8. #8
    hazeleyre23 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    34
    Ok thank you. Does the field have to be a specific type i.e combo box, textbox etc. As at the moment my field textbox therefore it is not giving me the option for Row Source.

    Thanks

  9. #9
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    please be clear about whether you are talking about fields or controls, they are different things. Fields are in tables and controls are in forms and reports and can be bound to a field (by entering the field name in the controls controlsource).

    if Date Chased is unbound put

    =addWorkDays(2, [Date Entered])

    in the control source


    if it is bound, put

    [Date Chased]=addWorkDays(2, [Date Entered])

    in the Date Entered afterupdate event

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

Similar Threads

  1. Replies: 1
    Last Post: 04-29-2016, 04:03 AM
  2. First and Last Working Days of Month
    By BLFOSTER in forum Queries
    Replies: 5
    Last Post: 05-01-2014, 03:14 PM
  3. Replies: 1
    Last Post: 11-26-2013, 09:25 AM
  4. Working Days From Todays Date
    By TimMoffy in forum Queries
    Replies: 2
    Last Post: 03-26-2013, 08:54 AM
  5. Replies: 6
    Last Post: 10-05-2012, 02:38 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
  •  
Other Forums: Microsoft Office Forums