Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help forming a query

Status
Not open for further replies.

mikedaruke

Technical User
Mar 14, 2005
199
US
Need help with SQL Query!

I have a bunch of dates like this

8/31/2005
9/1/2003
3/15/2001

In my MSQL database I have a date field in this format:

2005-08-31 00:00:05.000

I want to write some kind of query to say something like this:

select Id from table where date in ("8/31/2005', '9/1/2003')

Then it would return

ID, 2005-08-31 00:00:05.000

But it doesnt work with just having 8/31/2005 in the brackets, if I put the exact string 2005-08-31 00:00:05.000 it finds it.

Any help! Thanks
 
mysql requires that you specify all date values in year-month-day sequence

change it to

... where date in ('2005-08-31', '2003-09-01')


r937.com | rudy.ca
 
That doesn't work either. The problem is you have to have SQL compare it without the time portion I think
 
okay, right

in that case, use the DATE function

... where DATE(date) in ('2005-08-31', '2003-09-01')


r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top