Question

I am having one table where data gets every 15 min interval of timestamp like

2014-02-01 23:00:00
2014-02-01 23:15:00
2014-02-01 23:30:00
2014-02-01 23:45:00
2014-02-02 00:00:00

Now i want to dump this table data for last 24 hours. I am using MySQLDump to create dump file which will have following condition in it with where clause

-- WHERE:  DATE_FORMAT(emdt,'%d-%m-%Y')= DATE_FORMAT(NOW(),'%d-%m-%Y')

Now even with this condition i want to put one more logic is the data which get recorded at 2014-02-02 00:00:00' should also come under last 24 hours data but when it compared the data it is not picking up this data. Hence it is affecting last day billing.

So if i ran it next day same dump file it should only pickup records from 2014-02-02 00:15:00' and so on.

Please help me to put here right extraction login.

TIA, Regards, Nirav

Was it helpful?

Solution

Try using:

WHERE emdt >= DATE_SUB(NOW(), INTERVAL 1 DAY)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top