megs1328
02-05-2009, 04:47 PM
I currently have 3 columns: month, day, year. I would like to concatenate them in the WHERE clause like this:
CONCAT_WS('-', event.`year`, event.`month`, event.`day`) >= CURDATE()
so that I show only upcoming dates. the problem is, however, that if the month and day are single digits, there is no zero in front of them. so the string is coming out as
2009-4-5 >= 2009-04-05
Is there a way to add zeros to the single digits in the table itself or in the clause? When I try adding it in the table, it just deletes it. They are currently integers. I could make it a VARCHAR, but then it also depends on if the user enters it right. Is this even the best way to go about it? Thank you for your suggestions.
CONCAT_WS('-', event.`year`, event.`month`, event.`day`) >= CURDATE()
so that I show only upcoming dates. the problem is, however, that if the month and day are single digits, there is no zero in front of them. so the string is coming out as
2009-4-5 >= 2009-04-05
Is there a way to add zeros to the single digits in the table itself or in the clause? When I try adding it in the table, it just deletes it. They are currently integers. I could make it a VARCHAR, but then it also depends on if the user enters it right. Is this even the best way to go about it? Thank you for your suggestions.