Hi Folks, I have a MS Sql server database with a table named PTable with the following fields: Timeofflight =smalldatetime ie departure= varchar(10) ie toronto arrivalcity=varchar(10) ie new york Timeofflight departure arrivalcity 2012-07-12 12:42:00 London NewYork 2012-07-12 11:42:00 London Toronto 2012-07-12 08:42:00 Gatwick Montreal 2012-07-12 07:42:00 Frankfurt Toronto 2012-07-11 22:42:00 Milan London Present time getutcdate() I am trying to delete the rows which are 4 hours old. I tried many queries but not able to acompolish this task. So I am here to reqeuste for your help. Please give me a query which can select or delete the 4 hours old records. Your help will be much appreciated. regards, ws
SELECT * FROM PTable WHERE TimeOfFlight < DATEADD(hour, -4, GETUTCDATE()) That will select all the rows that are more than 4 hours old.