Comparison using mysql

This is a discussion on Comparison using mysql within the MySQL Database forums, part of the Database Forums category; Can i use the "LIKE" operator on a date in mysql? I want to compare the information by ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-09-2006
wesley@ispace.co.za
 
Posts: n/a
Default Comparison using mysql

Can i use the "LIKE" operator on a date in mysql?
I want to compare the information by the different months
Thanks Wesley

Reply With Quote
  #2 (permalink)  
Old 05-09-2006
strawberry
 
Posts: n/a
Default Re: Comparison using mysql

Sure, this query selects all orders placed in the month of April,
regardless of the year...

SELECT date FROM orders WHERE date LIKE '%-04-%';

Reply With Quote
  #3 (permalink)  
Old 05-09-2006
wesley@ispace.co.za
 
Posts: n/a
Default Re: Comparison using mysql

thanks:)

Reply With Quote
  #4 (permalink)  
Old 05-09-2006
Paul Lautman
 
Posts: n/a
Default Re: Comparison using mysql

strawberry wrote:
> Sure, this query selects all orders placed in the month of April,
> regardless of the year...
>
> SELECT date FROM orders WHERE date LIKE '%-04-%';


You can, but you can also do:

SELECT date FROM orders WHERE MONTH(date) = 4;


Reply With Quote
  #5 (permalink)  
Old 05-09-2006
wesley@ispace.co.za
 
Posts: n/a
Default Re: Comparison using mysql

that works brilliantly, thanks
Wes

Reply With Quote
  #6 (permalink)  
Old 05-09-2006
strawberry
 
Posts: n/a
Default Re: Comparison using mysql

Yes - but that wasn't the question ;-)

Reply With Quote
  #7 (permalink)  
Old 05-09-2006
Paul Lautman
 
Posts: n/a
Default Re: Comparison using mysql

strawberry wrote:
> Yes - but that wasn't the question ;-)


True, that was why I was careful to say "You can, but you can also..." :->


Reply With Quote
  #8 (permalink)  
Old 05-10-2006
wesley@ispace.co.za
 
Posts: n/a
Default Re: Comparison using mysql

Thanks strawberry and Paul
You guys are both brilliant;)
Wes

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:19 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0