anujgarg Posted October 1, 2008 Share Posted October 1, 2008 I am trying to converting a date to the number of days it is old. Means, I have the date in my DB as 2008-09-20 00:00:00 and I want to convert this to 11 as it is 11 days old from the current date. I am running a query of update as: select * from table where added_date = "2008-09-20 00:00:00" But I want this query to be executes as: select * from table where added_date = "11" (The total number of days it is old) How can I do it? Am I specific to my ques? Quote Link to comment Share on other sites More sharing options...
Barand Posted October 1, 2008 Share Posted October 1, 2008 DATEDIFF() gives number of days between two dates Quote Link to comment Share on other sites More sharing options...
jasonball76 Posted October 3, 2008 Share Posted October 3, 2008 Something like this? select * from table where date(added_date) = date(date_sub(now(), interval 11 day)) Quote Link to comment Share on other sites More sharing options...
aschk Posted October 3, 2008 Share Posted October 3, 2008 So what are you really asking for? a) you want all records that are 11 days old b) you want to show how old all the records are (in days). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.