![]() |
| Compare a Date field in Access to ASP date |
|
superjew1
|
I am having trouble comparing a date in the database to any of ASP date functions.
Page one. i have a select that populates from a database of all the dates on the column. Page two. i pass in the date from page one as a dim and i want to do a SQL like: "Select * from [table] where oDate = "'& date() &'" it gives me a data type mismatch error. any solutions??? thanks for all your help. |
||||||||||||
|
|
|||||||||||||
|
Josh
Forum Regular
|
Have you tried wrapping it in single quotes?
maybe even this will work:
Mind you, this returns the system date, so if you're in a time zone other than where the server is (or how it's set) then you should probably adjust your time accordingly. |
||||||||||||||||
|
|
|||||||||||||||||
| tried it. |
|
superjew1
|
I tried . What i really need to know is there a way to make something that is a dim a date field. that way it will compare them becuase they are the same field. i also tried making the field a varChar in access, but then it wouldnt order it properly.
|
||||||||||||
|
|
|||||||||||||
|
Josh
Forum Regular
|
Nah a date field in access should be datetime. Nothing else.
You know, what you could probably do is use the Date function in SQL...
|
||||||||||||||
|
|
|||||||||||||||
|
bobclingan
Forum Regular
|
I seem to remember having to use pound signs (#) around the date for something I was doing with Access.
|
||||||||||||
|
|
|||||||||||||
|
andrew
|
In MS SQL I often compare dates with datadiff function. I have never personally used ms access for web applications but it is a good bet that it has this function as well. Within an asp page the syntax would look like this:
That would return all the results from the target table where the 'target_column' is dated for the current day according the server where the page is hosted. Another date could easily be feed in to the query by changing the '& Date &' to a string formatted like mm/dd/yyyy. Again I am sorry to say I have never tried this with MS Access only SQL but it may be worth a shot. Complete DateDiff Syntax: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctdatediff.asp |
||||||||||||||
|
|
|||||||||||||||
|
Josh
Forum Regular
|
I didn't think DateDiff applied to what he was asking... he wasn't looking to pull a "range" of dates, just dates pertaining to the given day. I think bobum offered you a step in the right direction... wrapping your date in pound signs (#).
|
||||||||||||
|
|
|||||||||||||
| Compare a Date field in Access to ASP date |
|
||
|


