Results 1 to 4 of 4
  1. #1
    graviz is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Sep 2009
    Posts
    46

    Help Please - DateAdd Function

    I have a query with 5 fields:



    Month (The criteria is based upon a combobox on a form): i.e Feb
    Start Date: First day of the month on the month selected: i.e 2/1/10
    End Date: Last day of the month on the month selected: i.e. 2/28/10

    These two dates I wanted to calculate the start and end dates of the previous month selected: i.e. Jan
    New_SD: New_SD: DateAdd("m",-1,[Start_Date])
    New_ED: New_ED: DateAdd("m",-1,[End_Date])

    I thought I had it figured out but as you could see this will not work for the end date as Jan has 31 days and not 28. Can I modify my formula somehow to do this?

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,272
    You should find functions here to do the trick:

    http://www.pacificdb.com.au/Support/...hfunctions.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MAF4Fam6's Avatar
    MAF4Fam6 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Location
    Fruit Heights, Utah USA
    Posts
    140
    Quote Originally Posted by graviz View Post
    These two dates I wanted to calculate the start and end dates of the previous month selected: i.e. Jan
    New_SD: New_SD: DateAdd("m",-1,[Start_Date])
    New_ED: New_ED: DateAdd("m",-1,[End_Date])

    I thought I had it figured out but as you could see this will not work for the end date as Jan has 31 days and not 28. Can I modify my formula somehow to do this?
    Code:
    New_SD: DateAdd("m",-1,[Start_Date])
    New_ED: [End_Date]-Day([End_Date])
    -RC

  4. #4
    graviz is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Sep 2009
    Posts
    46
    Quote Originally Posted by pbaldy View Post
    You should find functions here to do the trick:

    http://www.pacificdb.com.au/Support/...hfunctions.htm
    This is an awesome resource for dates. Thanks again! Two in one day. Cross-answerer

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

Similar Threads

  1. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 AM
  2. Change Between by DateDiff or DateAdd.
    By wagner.bts in forum Queries
    Replies: 1
    Last Post: 06-05-2009, 11:24 AM
  3. function key
    By marianne in forum Access
    Replies: 5
    Last Post: 05-14-2009, 01:26 AM
  4. Avg Function
    By hiker8117 in forum Access
    Replies: 3
    Last Post: 04-23-2009, 11:14 PM
  5. Is there a function to do this....
    By Nowherefast in forum Access
    Replies: 2
    Last Post: 12-31-2008, 08:08 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 - Senior Forums