Results 1 to 5 of 5

Thread: Current Month

  1. #1
    Join Date
    Oct 2003
    Posts
    2

    Unanswered: Current Month

    I have a date field in the format mm/dd/yyyy. I want to create a select query that pulls only the records for the current month. I tried putting Month(Date()) in the criteria column of my date field but it didn't pick up any records. There are 2 records in the table with the current month in that field.

    Got any ideas? Thanks very much for your help.

  2. #2
    Join Date
    Aug 2003
    Location
    SW Ohio
    Posts
    198

    Re: Current Month

    WHERE Month(Date()) = Month(<FieldName>)
    Jim P.

    Supoorting Oracle, MSSQL7, Sybase 8, & Pervasive. Confusion Reigns

  3. #3
    Join Date
    Oct 2003
    Posts
    2

    Re: Current Month

    Originally posted by jimpen
    WHERE Month(Date()) = Month(<FieldName>)
    This goes in the criteria column for the date field in the query? I tried that and it gave me an error message "you have entered an operand without an operator."

    Sorry to be a dunderhead. I really appreciate your help.

  4. #4
    Join Date
    Sep 2003
    Location
    Los Angeles
    Posts
    103

    Re: Current Month

    Originally posted by DianeE
    This goes in the criteria column for the date field in the query? I tried that and it gave me an error message "you have entered an operand without an operator."

    Sorry to be a dunderhead. I really appreciate your help.
    If you are in query design-mode just put Month(Date()) in the criteria column of your date field.

    But if you are using SQL statement and VBA try this:

    dim strSQL as string
    dim rst as DAO.Recordset

    strSQL = "Select * from [table_name] where Month([date_field_name])= " & Month(Date())
    set rst = currentDB.openRecordSet(strSQL)

    while not rst.eof
    'retreive data and do whatever .. example
    debug.print rst!Any_filed_name
    ...

    wend

    ' Good Luck!

  5. #5
    Join Date
    Aug 2003
    Location
    SW Ohio
    Posts
    198

    Re: Current Month

    Put another column in your query Month(<FieldName> ) then down on the criteria line put Month(Date())
    Jim P.

    Supoorting Oracle, MSSQL7, Sybase 8, & Pervasive. Confusion Reigns

Posting Permissions

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