homepage Welcome to WebmasterWorld Guest from 54.145.183.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Is there a way to find the time and date an entry was added?
DigitalSky



 
Msg#: 4171063 posted 9:08 pm on Jul 15, 2010 (gmt 0)

Pretty simple question here (at least I think).

I'm fairly new to PHP/MySQL but I have a form where users can register. It stores all of their information in a MySQL database I created and it works great. The only thing I'm curious about is I would like to find dates/times for each individual entry so that I can see patterns and statistics with people who sign up. I'm using PHPMyAdmin and I'm not sure if there is a way to set this up on my table or not?

Any help would be greatly appreciated as I'm pretty new to MySQL as I said before.

 

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4171063 posted 8:25 am on Jul 16, 2010 (gmt 0)

you should look at the TIMESTAMP data type with a DEFAULT CURRENT_TIMESTAMP property [dev.mysql.com]

LifeinAsia

WebmasterWorld Administrator lifeinasia us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4171063 posted 3:31 pm on Jul 16, 2010 (gmt 0)

Assuming you have a DATETIME field in your DB that you populate when someone registers- yes, it is quite easy. If you are not already tracking the date that way, it would very difficult and would probably involve parsing through your DB's log file (icky!).

Demaestro

WebmasterWorld Senior Member demaestro us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4171063 posted 3:36 pm on Jul 16, 2010 (gmt 0)

Assuming you aren't tracking the time that entries are made you want to execute this:

alter table table_name add column date_entered TIMESTAMP;

Then...

alter table table_name alter column date_entered set default now();

This way you won't have to update any SQL statements that insert into your tables as this column will default to now() every time a new row is inserted.

Once you have that in place all you do is create a SQL statement that looks for rows with a date > then 7 days ago and < now()

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved