Results 1 to 4 of 4
  1. #1
    allenjasonbrown@gmail.com is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    44

    Using Current Date to find 16th

    Hello - I have a few queries that use date parameters. We use a 15th date as month end.
    Example Month - 05/16/2011 - 06/15/2011 (I usually just do a less than 06/16/2011 to make it easy).

    I have created these to figure out the 16th of the current month and the 16th of previous month:
    MONTH BEGIN: DateSerial(Year(Date()),Month(Date())-1,1)+15
    MONTH END: DateSerial(Year(Date()),Month(Date()),1)+15

    This will work great assuming the query runs between 06/16/2011 and 06/31/2011.

    MY QUESTION:
    Is there a way to create an IF statement and between the 16th of current month and 15th of next month, find the correct dates.

    FOR EXAMPLE -
    IF RUN TODAY I WANT - 05/16/2011 and 06/16/2011
    IF I RUN TOMORROW I WANT - 05/16/2011 and 06/16/2011
    IF I RUN 07/10/2011 I WANT - 05/16/2011 and 06/16/2011
    BUT....IF I RUN 07/16/2011 I WANT - 06/16/2011 and 07/16/2011

    Thanks in advance
    Last edited by allenjasonbrown@gmail.com; 06-30-2011 at 02:53 PM.

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Perhaps this:

    WHERE yourdatefield BETWEEN (IIF(day(date())>=16, dateserial(year(dateadd("m",-1,date())),month(dateadd("m",-1,date())),16), dateserial(year(dateadd("m",-2,date())),month(dateadd("m",-2,date())),16))) AND (IIF(day(date())>=16, dateserial(year(date()),month(date()),15), dateserial(year(dateadd("m",-1,date())),month(dateadd("m",-1,date())),15)))

  3. #3
    allenjasonbrown@gmail.com is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    44
    That seems too work great.....THANK YOU! (Ill do some more testing on the 1st).

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome. It is a little messy but functioned properly with some testing I did.

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

Similar Threads

  1. SQL Inner Join where date = current date
    By Tyork in forum Queries
    Replies: 2
    Last Post: 11-07-2010, 02:07 PM
  2. Replies: 3
    Last Post: 06-04-2010, 12:47 PM
  3. Comparing Date with current Date
    By ds_8805 in forum Forms
    Replies: 7
    Last Post: 03-31-2010, 09:31 PM
  4. Replies: 9
    Last Post: 03-19-2010, 10:37 AM
  5. Current Date Error
    By McFly in forum Database Design
    Replies: 4
    Last Post: 02-04-2010, 09: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