B
BruceM
A query includes an expiration date that can be several years in the future.
However, every year on the expiration month and day a notice needs to be
sent. The field in question is [EXP DATE]. For what its worth I would not
have a field name with a space, but I inherited the database. For the
criteria to retrieve only records with an expiration date between one month
in the past and one month in the future I use this:
Between DateSerial(Year(Date())+1,Month(Date())-1,Day(Date())) And
DateSerial(Year(Date())+1,Month(Date())+1,Day(Date())-1)
In the next three lines I repeat the criteria, except with +2, +3, and +4
for the Year part of DateSerial. +4 is as high as I ever need to go. It
works, but it seems awfully clumsy. I spent a long time trying to get
DateSerial to help me, but it can't since the results of the function
apparently are not evaluated as a date. For instance, instead of the above
criteria in [EXP DATE] I applied criteria to filter out records with the
expiration date this year, then I added a calculated field to the query:
ReviewDate: DateSerial(Year(Date()),Month([EXP DATE]),Day([EXP DATE]))
This produces 2/12/05 if the expiration date is 2/12/06 or 2/12/07, for
instance. Looks good, but worthless. When I attempted to apply criteria I
received a Data type mismatch in criteria expression error message. Here is
the criteria I attempted:
Between DateSerial(Year(Date()),Month([EXP DATE])-1,Day([EXP DATE])) And
DateSerial(Year(Date()),Month([EXP DATE])+1,Day([EXP DATE])-1)
I also created query fields using DatePart to extract Month and Day, and
used those fields in the criteria instead of [EXP DATE], but again it did not
work. Can what I am attempting be done?
However, every year on the expiration month and day a notice needs to be
sent. The field in question is [EXP DATE]. For what its worth I would not
have a field name with a space, but I inherited the database. For the
criteria to retrieve only records with an expiration date between one month
in the past and one month in the future I use this:
Between DateSerial(Year(Date())+1,Month(Date())-1,Day(Date())) And
DateSerial(Year(Date())+1,Month(Date())+1,Day(Date())-1)
In the next three lines I repeat the criteria, except with +2, +3, and +4
for the Year part of DateSerial. +4 is as high as I ever need to go. It
works, but it seems awfully clumsy. I spent a long time trying to get
DateSerial to help me, but it can't since the results of the function
apparently are not evaluated as a date. For instance, instead of the above
criteria in [EXP DATE] I applied criteria to filter out records with the
expiration date this year, then I added a calculated field to the query:
ReviewDate: DateSerial(Year(Date()),Month([EXP DATE]),Day([EXP DATE]))
This produces 2/12/05 if the expiration date is 2/12/06 or 2/12/07, for
instance. Looks good, but worthless. When I attempted to apply criteria I
received a Data type mismatch in criteria expression error message. Here is
the criteria I attempted:
Between DateSerial(Year(Date()),Month([EXP DATE])-1,Day([EXP DATE])) And
DateSerial(Year(Date()),Month([EXP DATE])+1,Day([EXP DATE])-1)
I also created query fields using DatePart to extract Month and Day, and
used those fields in the criteria instead of [EXP DATE], but again it did not
work. Can what I am attempting be done?