Calculations

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Harlequin
Forum Commoner
Posts: 51
Joined: Tue Sep 21, 2004 10:51 am
Location: UK

Calculations

Post by Harlequin »

Hi all.

I'm trying to perform the following calculation:

Take yesterday's number of "Active Users" away from today's number of "Active users" and present the results.

I have a query that's executed each time a page is opened that inserts Date/Time into a field and number of active users.

How can I grab the last entry before today's date though and use that value...?

Hope I've explained that OK.

I'm using the Date/time format of:

Code: Select all

$Time = date("Y-m-d H:i:s");
So now would be: 2004-10-15 13:13:45

Is what I am asking impossible maybe...?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Might want to use the unix epoch time to make things a bit easier and then you just select the stuff from the database:

Code: Select all

SELECT count(entried) FROM blah WHERE date_entered BETWEEN '214342432' AND '543354435354'
etc. And work out the time value for the query by doing a mktime().
Post Reply