Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Compare Month and Year in QueryDef (Access 2000)

    I have a form which is used to get data based on the month and year the user has selected. In my query, I have a column called InvoiceDateIn which is a date (in the short date format) and I would like to do a comparision of the month and year with the value selected from a form. How can I get compare just the month and the year of the column InvoiceDateIn?

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Compare Month and Year in QueryDef (Access 2000)

    There are two ways you can do this:

    1. Add columns InvoiceMonth: Month([InvoiceDateIn]) and InvoiceYear: Year([InvoiceDateIn]) and compare these to the month and year selected by the user. Set the criteria to something like Forms!frmWhatever!txtMonth and Forms!frmWhatever!txtYear where frmWhatever is the name of the form and txtMonth and txtYear are the names of the controls in which the user selects month and year.

    - or -

    2. Add a column InVoiceMonth: DateSerial(Year([InvoiceDateIn]), Month([InvoiceDateIn]), 1). This will contain the first day of the month of InvoiceDateIn. Set the criteria to DateSerial(Forms!frmWhatever!txtYear, Forms!frmWhatever!txtMonth, 1) with the same notation as above.

  3. #3
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compare Month and Year in QueryDef (Access 2000)

    Awesome [img]/forums/images/smilies/smile.gif[/img]

    Thanks

Posting Permissions

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