Click here to Skip to main content
15,935,429 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I was trying to make a query that would delete the rows according to the current date. it worked. but now, I wished if its possible to delete the data on a specified time. so the user can select when he/she wishes to delete the data. for example 4am. how do i do that with the current code I have. Please help.

SQL
mysql_query("DELETE FROM `sec_codes` WHERE DATE(date) < CURDATE()");
Posted

 
Share this answer
 
CurTime() is also the Smae function as CurDate(); So if CurDate() is Working then CurTime() should also work.
Try it.
 
Share this answer
 
Hi,Go through the following code you can change the condition as you want.You can pass the parameter for date time on which you want to delete the record. I have commented code for delete query first check with select then if it is ok then execute delete statement

declare @date1 varchar(16)
--set @date1='2013-02-24 01:10'
set @date1=convert(varchar(10),getdate(),120)+' 01:35:00'
select *,convert(datetime,rct,111)
--,@date1
from photo_test where convert(datetime,rct,111) > convert(datetime,@date1,111)

--Delete from photo_test where convert(datetime,rct,111) > convert(datetime,@date1,111)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900