query by enter month number?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all, i thought i would be able to achieve this alone and by searching the
posts on dates, but no.

I would like my query to return records completed in a specific month number
and by the current year.

any help appreciated.
 
Maax said:
Hi all, i thought i would be able to achieve this alone and by
searching the posts on dates, but no.

I would like my query to return records completed in a specific month
number and by the current year.

any help appreciated.

SELECT *
FROM TableName
WHERE DateField >= DateSerial(YearDate()), [Enter Month Number], 1)
AND DateField < DateSerial(YearDate()), [Enter Month Number] + 1, 1)
 
Hi Rick, thanks for reply. I have used the following,

Criteria: Between DateSerial(Year(Date()), [Enter month NUMBER (1-12)],1)
AND DateSerial(Year(Date()),1+ [Enter month NUMBER (1-12)],0)

I took this from another post. I am unsure what the 1 and 0 are used for in
the above though.

it seems to be doing the job though.



Rick Brandt said:
Maax said:
Hi all, i thought i would be able to achieve this alone and by
searching the posts on dates, but no.

I would like my query to return records completed in a specific month
number and by the current year.

any help appreciated.

SELECT *
FROM TableName
WHERE DateField >= DateSerial(YearDate()), [Enter Month Number], 1)
AND DateField < DateSerial(YearDate()), [Enter Month Number] + 1, 1)
 
Just an FYI, you should check out DatePart and Format.

For a date of 10/26/05

DatePart("m", [Date]) will show 10
DatePart("yyyy", [Date]) will show 2005
Format([Date],"mmm") will show Oct
Format([Date],"mmmm") will show October
 
Maax said:
Hi Rick, thanks for reply. I have used the following,

Criteria: Between DateSerial(Year(Date()), [Enter month NUMBER
(1-12)],1) AND DateSerial(Year(Date()),1+ [Enter month NUMBER
(1-12)],0)

I took this from another post. I am unsure what the 1 and 0 are used
for in the above though.

it seems to be doing the job though.

As long as your DateTime field always has midnight for the time that will
work. Otherwise you will get nothing from the end date except those records
that do have midnight for the Time. Using < on one day past the end date
you want eliminates that issue.
 
Back
Top