Jump to content


Photo

Number of days


  • Please log in to reply
1 reply to this topic

#1 master82

master82
  • Members
  • PipPipPip
  • Advanced Member
  • 182 posts

Posted 23 March 2006 - 06:55 PM

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?

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 24 March 2006 - 01:18 PM

SELECT ( TO_DAYS(CURDATE()) - TO_DAYS(created) ) as totaldays

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users