Results 1 to 4 of 4
  1. #1
    dharsh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    19

    Date Calculation

    I have a date field called [BDM Start Date]. I need to add 180 days to this date and then round it to the 1st of the next month. Can anyone help me with this? I am using Access 2010. Thanks

  2. #2
    Martinc4611 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    4
    You could do something like this:

    Function NewDate()

    Dim Startdate As Date ' your date field
    Dim dd As Integer ' days

    'initalize startdate value
    Startdate = Now()

    Startdate = Startdate + 180
    dd = Format(Startdate, "d")

    'Check for StartDate = first day of month, advance 1 day.
    If dd = 1 Then Startdate = Startdate + 1

    'Loop to get first day of next month
    Do Until dd = 1
    Startdate = Startdate + 1
    dd = Format(Startdate, "d")
    Loop

    MsgBox Startdate
    End Function

  3. #3
    dharsh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    19
    I am a novice in Access. Is there an easier way to do this in a query?

  4. #4
    Martinc4611 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    4
    No easy way that i know of. Here is a way you can do it in a query.

    1. Create a new module in Access. Copy the code below and save it.
    2. In your query, paste the following in a new field: NewDate: CalcDate([Modified_Date])
    3. Run your query. The field NewDate will contain the information you are looking for.

    copy this to a new module.

    Function CalcDate(OldDate As Date)

    Dim dd As Integer ' days

    OldDate = OldDate + 180
    dd = Format(OldDate, "d")

    'Check for StartDate = first day of month, advance 1 day.
    If dd = 1 Then OldDate = OldDate + 1

    'Loop to get first day of next month
    Do Until dd = 1
    OldDate = OldDate + 1
    dd = Format(OldDate, "d")
    Loop

    CalcDate = OldDate
    End Function

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

Similar Threads

  1. Some help with Date calculation
    By djclntn in forum Queries
    Replies: 14
    Last Post: 04-13-2013, 05:26 PM
  2. Date Calculation
    By logle0917 in forum Reports
    Replies: 3
    Last Post: 08-06-2012, 08:18 PM
  3. Date Calculation
    By mrkaye in forum Forms
    Replies: 4
    Last Post: 11-10-2010, 10:42 AM
  4. Date Calculation ?
    By techexpressinc in forum Queries
    Replies: 2
    Last Post: 06-24-2009, 09:02 PM
  5. Date Calculation -- HELP!
    By klaauser in forum Forms
    Replies: 0
    Last Post: 12-22-2008, 02:14 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