date troubles (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


pd_it_guy -> date troubles (6/18/2008 15:13:43)

Ok I have been at this for a couple of hours now and I am going exactly nowhere. The database has a field called into_pd which is a date. It is designated within the .mdb as a date/time field and no matter what variant the users input as a date, it ends up in the .mdb in a good format, all leading zeros lopped. Now I want to get all the records between 2 dates I select. The dates come from another form and as user input can be input any which way. The Query to get only the right dates is the problem.

WHERE into_pd>='::start_date::' AND into_pd<='::end_date::'

causes a type mismatch

WHERE into_pd>=::start_date:: AND into_pd<=::end_date::

fixes the type mismatch error, but returns nothing when I know there are records between those dates. If I pull off one of the operators I do get some records returned but the comparison is not on the actual date value, but something else. It is not doing a date evaluation or doesnt see it as a date.

What am I doing wrong here.




DesiMcK -> RE: date troubles (6/18/2008 17:13:57)

try

WHERE into_pd>=#" & Request("start_date") & "# AND into_pd<=#" & Request("end_date") & "#"

Desi




pd_it_guy -> RE: date troubles (6/18/2008 17:40:16)

Thanks for the response.

I came across the DATEVALUE function and it seems to convert everything to a common denominator and thereby makes it work, thus:

WHERE datevalue(into_pd) BETWEEN datevalue('::start_date::') AND datevalue('::end_date::')

Someone please tell me if I am making a grave error with this code. If so or if it fails I will keep the suggested lines as well. This was my first time dealing with dates in Access, all the other date manipulation stuff was in Informix, which gives you a date and that's all.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875