Jump to content

Archived

This topic is now archived and is closed to further replies.

master82

Number of days

Recommended Posts

In my users table in my mysql database I have the field "created", in the format of CURRENT_TIMESTAMP (which upon inserting a new record uses NOW() as a default) resulting in a format of 2006-03-21 12:48:14.
I use this as when a member registers it automatically places the date and time within.

Now what I need is to create a php page with all the members information, including the number of days they have been a member.

I've tried to place the created date into a variable and used NOW(), DATE(), TIME(), CURDATE(), CURTIME() etc to get the current date (subtracting one from the other) but it doesnt seem to work when trying to subtract the two dates.

Also I need the result displayed in number of days.


Anyone know how I can proceed to achieve this?

Share this post


Link to post
Share on other sites
[code]SELECT ( TO_DAYS(CURDATE()) - TO_DAYS(created) ) as totaldays[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.