date comparison - year not working

neilakoga

New member
Local time
Today, 06:49
Joined
Apr 14, 2010
Messages
1
ok, I'm trying to select a date range (particular month and year). [FONT=Verdana, Arial, Helvetica]here's my date range comparison. it's working for months but not years - anyone got any ideas? i'm calling the query from an asp.net page

"SELECT orderNum, orderDate, bName, bCompany, orderStatus FROM tblOrderAddr WHERE (format(orderDate, 'mm/dd/yyyy hh:min:ss') >= format(" & date1 & ", 'mm/dd/yyyy hh:min:ss')) AND (format(orderDate, 'mm/dd/yyyy hh:min:ss') <= format(" & date2 & ", 'mm/dd/yyyy hh:min:ss')) and orderStatus <> 'Completed'"

date1 and date2 are strings i pass in and they look like this if i'm searching for something from april 2010

#04/01/2010# #04/30/2010#
[/FONT]
 
If they are strings, try converting them to dates by using CDate. e.g. CDate([date1])

Dan
Access Development

ok, I'm trying to select a date range (particular month and year). [FONT=Verdana, Arial, Helvetica]here's my date range comparison. it's working for months but not years - anyone got any ideas? i'm calling the query from an asp.net page[/FONT]

[FONT=Verdana, Arial, Helvetica]"SELECT orderNum, orderDate, bName, bCompany, orderStatus FROM tblOrderAddr WHERE (format(orderDate, 'mm/dd/yyyy hh:min:ss') >= format(" & date1 & ", 'mm/dd/yyyy hh:min:ss')) AND (format(orderDate, 'mm/dd/yyyy hh:min:ss') <= format(" & date2 & ", 'mm/dd/yyyy hh:min:ss')) and orderStatus <> 'Completed'"[/FONT]

[FONT=Verdana, Arial, Helvetica]date1 and date2 are strings i pass in and they look like this if i'm searching for something from april 2010[/FONT]

[FONT=Verdana, Arial, Helvetica]#04/01/2010# #04/30/2010#[/FONT]
 

Users who are viewing this thread

Back
Top Bottom