Date condition in between function MySql Query
Mostly in games we have requirement like information of player, those who are played in the last week. Here is the simple mysql query to check players who are played last week.
We use simple mysql function to fetch result from the mysql table. MySql functions are
1.NOW()
2.DATE_SUB()
3.BETWEEN
where
NOW()- is mysql date function which returns present date and time. ex. 2012-11-17 12:04:26
DATE_SUB(NOW(), INTERVAL 7 DAY) – this date function subtracts 7 days from present date,
here present date is 2012-11-17 12:04:26
subtracted output is 2012-11-10 12:04:26
here is the sample table player table
Result :
MySQL Query is
SELECT name, city, score FROM player_information where played_on BETWEEN DATE_SUB(NOW(), INTERVAL 7 DAY) and NOW()
The above query get player information those who played last week..
Download Premium Only Scripts & 80+ Demo scripts Instantly at just 1.95 USD per month + 10% discount to all Exclusive Scripts
If you want any of my script need to be customized according to your business requirement,
Please feel free to contact me [at] muni2explore[at]gmail.com
Note: But it will be charged based on your customization requirement