ID Name curdate
1 John 2014-10-08
2 Steve 2014-09-06
3 Mark 2014-06-07
FROM (SELECT p.*, SUBSTR(p.`curdate`,1,4) AS d_year, SUBSTR(p.`curdate`,6,2) AS d_month, SUBSTR(p.`curdate`,9,2) AS d_day FROM profile AS p) AS rs WHERE rs.d_month IN ('10','06');
Anyone knows how to implement this query in activerecords?.
The reason why i want this query, Its because i want a custom search of curdate by year, month, day. I don’t know how to execute this.
pls help. thank you.
I think you could use some mysql date functions to help you out instead of using substrings.
For your example, something like this should work:
SELECT * FROM profile WHERE month(curdate) IN (10, 6);
thank you so much sir. I didn’t know the month function can be use in searching. hehehe thanx.