P
PC Datasheet
An Access user saw my name in a newsgroup and sent me a request for help on
a project. As part of the project, a list of the dates in a month was
needed. For anyone needing a list of dates in a month, here is what I used:
1. Create a table named TblNumbers with one field named Num and populate
the table with 1 to 31
2. Create a query based on TblNumbers
3. Pull down Num into the first field of the query.
4. Put the following expression in the criteria for Num:
<=Day(DateSerial(6,1+1,0))
5. Put the following expression in the second field of the query:
MonthDate: DateSerial(6,1,[Num])
6. Put the following expression in the third field of the query:
=Day([MonthDate])
7. Put the following expression in the fourth field of the query:
=Format([MonthDate],"ddd")
8. Put the following expression in the fifth field of the query:
= Format([MonthDate],"dddd")
9. Run the query.
The query will return all the dates for this month (January 06) in the
second column. The third column will contain the day of the month for each
date. The fourth column will contain the three letter abbreviation for the
day of the week for each date. The fifth column will contain the full name
of the day of the week for each date.
In the DateSerial expression, 6 is the year (06) and 1 is the number of the
month. You can make the query return the dates for any year and month by
modifying the DateSerial function to make the 6 and 1 selectable on a form.
a project. As part of the project, a list of the dates in a month was
needed. For anyone needing a list of dates in a month, here is what I used:
1. Create a table named TblNumbers with one field named Num and populate
the table with 1 to 31
2. Create a query based on TblNumbers
3. Pull down Num into the first field of the query.
4. Put the following expression in the criteria for Num:
<=Day(DateSerial(6,1+1,0))
5. Put the following expression in the second field of the query:
MonthDate: DateSerial(6,1,[Num])
6. Put the following expression in the third field of the query:
=Day([MonthDate])
7. Put the following expression in the fourth field of the query:
=Format([MonthDate],"ddd")
8. Put the following expression in the fifth field of the query:
= Format([MonthDate],"dddd")
9. Run the query.
The query will return all the dates for this month (January 06) in the
second column. The third column will contain the day of the month for each
date. The fourth column will contain the three letter abbreviation for the
day of the week for each date. The fifth column will contain the full name
of the day of the week for each date.
In the DateSerial expression, 6 is the year (06) and 1 is the number of the
month. You can make the query return the dates for any year and month by
modifying the DateSerial function to make the 6 and 1 selectable on a form.