[thelist] date time calculation query

Hassan Schroeder hassan.schroeder at gmail.com
Tue Sep 20 17:10:44 CDT 2011


On Tue, Sep 20, 2011 at 2:58 PM, Bob Meetin <bobm at dottedi.biz> wrote:
> I am writing a query against an existing database/table in which I need to
> qualify whether the member's subscription is active. Typically when I write
> these types of queries the 2 dates are in some date type, but here they are
> int(11) and I presume that the number is relevant to some date from point in
> time, but of course I'm unfamiliar with this method of doing calculations.
>
> The values:
>
> +----+---------+---------------+------------------+----------------+
> | id | user_id | membership_id | membership_start | membership_end |
> +----+---------+---------------+------------------+----------------+
> |  1 |      62 |             2 |       1316571958 |     1319163958 |
> |  2 |      62 |             1 |       1316572508 |     1319164508 |
> +----+---------+---------------+------------------+----------------+

Presuming MySQL --

mysql> select from_unixtime(1316571958);
+---------------------------+
| from_unixtime(1316571958) |
+---------------------------+
| 2011-09-20 19:25:58       |
+---------------------------+

mysql> select from_unixtime(1316571958, '%Y');
+---------------------------------+
| from_unixtime(1316571958, '%Y') |
+---------------------------------+
| 2011                            |
+---------------------------------+

Not sure why someone would choose that format over a standard
date or datetime, but...

HTH!
-- 
Hassan Schroeder ------------------------ hassan.schroeder at gmail.com
http://about.me/hassanschroeder
twitter: @hassan


More information about the thelist mailing list