Disasterpiece Posted April 22, 2003 Posted April 22, 2003 Can you use (>) and (<) in SQL statements when refering to a Date format column? Say I want to get all of the rows from only a certain date forward, would this work: "SELECT * FROM Transactions WHERE DATE > '" & dteDate & "'" If not, would I have to use a BETWEEN statement instead? Thanks Quote
digitalenigma Posted April 22, 2003 Posted April 22, 2003 Yes, you can use the > < operators on date fields. However, depending on your data source, you have to specify that the value being evaluated is a date. For example, in Access, you would write the following: "SELECT * FROM TRANSACTIONS WHERE DATE > #" & dteDate & "#" Quote
Leaders quwiltw Posted April 22, 2003 Leaders Posted April 22, 2003 That will work in SQL Server. Not sure abou the others. It wouldn't hurt anything to try it. You'd get the answer a *lot* quicker too. Quote --tim
digitalenigma Posted April 22, 2003 Posted April 22, 2003 If you are using Oracle, use the following syntax: "SELECT * FROM TRANSACTIONS WHERE DATE > {ts '" & dteDate & "'}" The general format is: "SELECT * FROM TRANSACTIONS WHERE DATE > {ts '2002-11-06 18:24:25'}" There are, of course, various formats you can use. But use "-" instead of "/" as separators. From my experience, Oracle likes them better. Hope that helps. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.