I am trying to convert a working MS Access query to run on an Oracle database being accessed via VB Script (.asp). This is the last section of the WHERE clause:
sql = sql & "WHERE (UAT.HB.MB_MODE = 'A' AND UAT.HB.PRINT_DATE >= '"
& SD & "' AND UAT.HB.PRINT_DATE <= '" & ED &"' )"
The variable "SD" (i.e. "start date") is a text string that can contain a value such as "11/11/2008". The same goes for the variable "ED" (i.e. "end date").
However, the dates do not work. Does Oracle require a special way to use dates?
Do the dates have to be converted? Do I surround them with the '#' keyword like you would in MS Access?
In Oracle, your date should be written as an ANSI date literal like this:
DATE '2008-11-11'
Or converted to a date from a string like this:
TO_DATE('11/11/2008', 'MM/DD/YYYY')
See here
Don't assume the default Oracle date format is anything. Check the NLS_DATE_FORMAT or use TO_DATE to convert it. Like this:
TO_DATE('2008-11-18 14:13:59', 'YYYY-MM-DD HH24:Mi:SS')
Note the 'Mi' for the minutes and not 'MM'. That catches a lot of people.
according to this you can use the following:
to_date('19960725','YYYYMMDD')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With