Rounding off dates

  • Thread starter Thread starter JamesA
  • Start date Start date
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
 
Hi,


DateValue( parameter )

would take only the date part; TimeValue( x ) would take only the time.


Hoping it may help,
Vanderghast, Access MVP
 
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
 
Back
Top