CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2007
    Posts
    14

    First of next month

    I need to add a piece of criteria to a report.

    It needs to say:

    if datepurchased = 1st of next month then ......


    Thank you for your help.
    Rachel

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: First of next month

    Use the DAY() function
    Code:
    if Day(myDate)=1 then msgbox "First of the Month"
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    May 2007
    Posts
    14

    Re: First of next month

    This report can be ran on any day, I need to know how to - for example:

    its the 15th of may and I run this report, i need all records that the datepurchased is = the the first of the following month (april).

    So, i would need the first of next month.

    Rachel

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: First of next month

    You can get the current day and also the current month. Add 1 to the month, using DateAdd(), then get the first day to use in the sql statement.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    May 2006
    Posts
    324

    Re: First of next month

    Look in the help at DateSerial.
    DateSerial(Year(d), Month(d) + 1, 1)

  6. #6
    Join Date
    May 2007
    Posts
    14

    Re: First of next month

    Thank you... I will check into it, at a quick glance i think that will work...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured