Forum Moderators: open

Message Too Old, No Replies

Adding to datetime field from another field while selecting!

         

smagdy

7:08 pm on Apr 23, 2007 (gmt 0)

10+ Year Member



Hello,

I think this query was working but suddenly it isnt giving same right results so i am wondering if its right or any other way to run it!

The thing is that "num_of_days" is has the number of day that needs to be added and it is another field in same table!

SELECT `id`
FROM alerts
WHERE DATE_ADD(datetime, INTERVAL num_of_days DAY ) < NOW( )

Thanks in advance

smagdy

9:22 am on Apr 24, 2007 (gmt 0)

10+ Year Member



Anybody?

Its simple question i guess!

smagdy

11:24 am on Apr 24, 2007 (gmt 0)

10+ Year Member



It worked by adding TRIM to the num_of_day!

Its strange because the values are ENUM and they got no spaces:

enum('7', '14', '30', '60')

Thanks anyways

coopster

1:32 am on Apr 27, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



If you retrieve an ENUM value in a numeric context, as you are, the column value's index is returned. By using TRIM you are looking for the string value of the index.