Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date comparisons

Status
Not open for further replies.

rorymurray

Programmer
Oct 16, 2001
44
AU
I am trying to get a date from a text box in a form, then use it in a query.
Basically in the query I want to make the condition:

<[Forms]![Main]![EndDate] .

This gives me incorrect results. I realise that normaly if I knew the date I could put something like:

<#01/01/02# , but what is the syntax for using the value from a form?

Rory
 
Hi

If you are building an SQL string, the date must be in us format (ie mm/dd/yyyy) and must be bounded by #, so if you are in the US then you just need to use:

&quot;SELECT ... WHERE datDate < #&quot; & [Forms]![Main]![EndDate] & &quot;# ....&quot; .

if you are not in the US

&quot;SELECT ... WHERE datDate < #&quot; & Format([Forms]![Main]![EndDate],&quot;mm/dd/yyyy&quot;) & &quot;# ....&quot;

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Thanks. I knew it was something simple, the Format() function was what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top