Question Query builder and date field in table

mrojas

Member
Joined
May 4, 2009
Messages
11
Location
Concord, Ca.
Programming Experience
5-10
I'm building a simple MS Access front end application to display in a grid records from one table based date field using the Query Builder. So far I've been able to display all records in the dataset if I don't enter a parameter, but when I try to filter records with a date >= today, the query builder chokes.
Here's my query syntax:
SELECT Speaker FROM tblSpeakers WHERE TalkDate>=Now

The query works if I use a literal date such as TalkDate>=#12/10/2012# but not with anything else I can think of.
:uncomfortableness:
 
Hi,

It is usually date formatting / cultural issues that cause problems like this in access. To get round this try using DateSerial. i.e:-

TalkDate>= DateSerial(Year(Now()),Month(Now()),Day(Now()))

Hope that helps.

Cheers,

Ian
 
Try TalkDate>=" & CDate(Now) & " ............

You may need TalkDate>=#" & CDate(Now) & "# ............

The function NOW returns date AND time information that crocks the >=
 
Date field in query builder

Try TalkDate>=" & CDate(Now) & " ............

The syntax that eventually worked for me was:
(TalkDate >= CDATE(Now))

Using # symbols around the CDATE(Now) caused compiler to balk at it every time.

The other version of the syntax suggested, TalkDate>= DateSerial(Year(Now()),Month(Now()),Day(Now())) did not work either. It generated an error stating "undefined YEAR function."

Thanks to all those that replied.
 
Back
Top