Rounding off dates

J

JamesA

My startDate and FinshDate are populated with the DTPicker
and that adds on time. How can I put in a date (without
the time) in query criteria section to get it to work?
Please very urgent.

Regards,
JKA
 
D

Dale Fye

If you are using these two dates in a query, and the field that they
are being tested against has a date and a time value (usually because
the Now() function was used as the default for the field), then you
will need to do something like:

SELECT * FROM yourTable
WHERE DateValue(yourDateField) Between startDate and endDate

This version just strips the time value off of your date field, which
may be sufficient. Or, you could use:

SELECT * FROM your Table
WHERE startDate <= yourDateField
AND yourDateField < DateAdd('d', 1, DateValue(endDate))

This second method effectively adds a day to your endDate variable,
but since the time stamp will be midnight, it will return all the
values right up to 11:59:59.9999 PM

--
HTH

Dale Fye


My startDate and FinshDate are populated with the DTPicker
and that adds on time. How can I put in a date (without
the time) in query criteria section to get it to work?
Please very urgent.

Regards,
JKA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top