Creating a Variable of Present Date Minus a Past Timestamp

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-06-02T20:40:33Z Indexed on 2010/06/02 20:44 UTC
Read the original article Hit count: 247

Filed under:
|

Hello,

In the code below, "created" is a field in a MySQL table. This field is of the type "timestamp" and the default is set to "CURRENT_TIMESTAMP" of whenever a given row is created.

In the query below, I would like to create a new variable that equals the present date minus the timestamp of "created", rounded off to units of days. I would like the present date to be whenever the query is run.

How could I do this?

Thanks in advance,

John

$sqlStr = "SELECT 
    l.loginid, 
    l.username, 
    l.created,
    ...

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql