I have two date strings, in the format MM/DD/YYYY and would like to query an Oracle database for any records between those two dates. How do I do this succinctly and simply?
+1
A:
Try this,
SELECT * FROM table WHERE date BETWEEN to_date('01/05/2010','mm/dd/yyyy') AND to_date('10/01/2010','mm/dd/yyyy') ORDER BY date ASC
Riddari
2010-07-30 20:59:25
Answered your own question inside of two minutes, eh?
OMG Ponies
2010-07-30 21:00:47
Yeah, usually I use SO as a parallel research tool. If I need to know something, I'll set the community on it on SO and search for the answer myself at the same time.
Riddari
2010-08-03 15:24:50
@Riddari wow - really? Remind me not to spend time on your questions until I give you some time to try a search engine first.
Christopherous 5000
2010-08-03 15:38:01
Also I think this one in particular I didn't find a good source for elsewhere, so I put it here for others to find.
Riddari
2010-08-03 16:39:39
+3
A:
Use the TO_DATE function:
WHERE date_column BETWEEN TO_DATE(start, 'MM/DD/YYYY')
AND TO_DATE(end, 'MM/DD/YYYY')
OMG Ponies
2010-07-30 21:00:07