Unix Technical Forum

date comparaison in SELECT IF(), not working

This is a discussion on date comparaison in SELECT IF(), not working within the MySQL forums, part of the Database Server Software category; --> Hello there, Can't one use date comparaison in a SELECT IF statement? Can't get it to work... this query ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 10:11 AM
zorro
 
Posts: n/a
Default date comparaison in SELECT IF(), not working

Hello there,

Can't one use date comparaison in a SELECT IF statement? Can't get it
to work...

this query works, it returns 3 rows:
select EntryDate from Feedback where EntryDate > DATE_SUB(NOW(),
INTERVAL 10 DAY)

inside an IF, the same comparaison formula does not work - Answer is
always NO
select IF( EntryDate > DATE_SUB(NOW(), INTERVAL 10 DAY), 'YES',
'NO' ) as Answer from Feedback


EntryDate type is 'datetime'.

Using MySQL 4.0.25-standard
so can't use DATE() or DATEDIFF()

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 10:11 AM
zorro
 
Posts: n/a
Default Re: date comparaison in SELECT IF(), not working

DOH!!!
Of course it works, just wasn't seeing all rows - phpMyAdmin shows
just 30 at a time !!


boo hoo hoo, wasted 45 minutes


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 10:11 AM
Brian Wakem
 
Posts: n/a
Default Re: date comparaison in SELECT IF(), not working

zorro wrote:

> DOH!!!
> Of course it works, just wasn't seeing all rows - phpMyAdmin shows
> just 30 at a time !!



By default, yes.

Edit this row in the config file to change this behaviour:

$cfg['MaxRows'] = 30; // maximum number of rows to display



--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:08 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com