Home > Archive > PHP DB > March 2005 > RE: [PHP-DB] Newbie: phpmyadmin and searching Unix Timestamps
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
RE: [PHP-DB] Newbie: phpmyadmin and searching Unix Timestamps
|
|
| Bastien Koert 2005-03-22, 8:55 pm |
| SELECT date_format(FROM_UNIXTIME(875996580),'%Y
-%m-%d'); is what I used
yesterday to get around this problem
bastien
>From: Graham Anderson <grahama@siren.cc>
>To: php-db@lists.php.net
>Subject: [PHP-DB] Newbie: phpmyadmin and searching Unix Timestamps
>Date: Tue, 22 Mar 2005 12:10:15 -0800
>
>is there an easy way to search through unixtimestamps ?
>
>like
>Select * from SessionTable Where ConvertToMonthFunction(unixTimeStamp) =
>'March' ?
>
>be great to use the Variable function within phpmyAdmin
>
>many thanks
>g
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
| |
| Graham Anderson 2005-03-22, 8:55 pm |
| So how would you build the query without knowing the unix TimeStamp as
'1111527115' is the current date ? I am trying to build the query so
it dynamically know what to look for
like
SELECT * FROM SessionTable WHERE MONTH(from_unixtime(all available
records)) = 'March';
is something like this possible ?
many thanks
g
On Mysql (works on 4.0 atleast), you can use the FROM_UNIXTIME()
function to convert a unix timestamp back to universal date/time
format. From then on you can use any standard mysql date/time functions
to compare the month. So your query becomes something like:
SELECT * FROM SessionTable WHERE MONTH(from_unixtime(1111527115)) = 3;
MONTH() returns a numeric month number from 1-12. See the mysql
documentation on date and time functions here:
http://dev.mysql.com/doc/mysql/en/d...-functions.html
Hope this helps.
On Mar 22, 2005, at 1:35 PM, Bastien Koert wrote:
> SELECT date_format(FROM_UNIXTIME(875996580),'%Y
-%m-%d'); is what I
> used yesterday to get around this problem
>
> bastien
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
| |
| Bastien Koert 2005-03-22, 8:55 pm |
| SELECT * FROM SessionTable WHERE date_format((from_unixtime(fieldname),'%
M')
= 'March';
should do the trick
bastien
>From: Graham Anderson <grahama@siren.cc>
>To: php-db@lists.php.net
>Subject: Re: [PHP-DB] Newbie: phpmyadmin and searching Unix Timestamps
>Date: Tue, 22 Mar 2005 15:06:35 -0800
>
>So how would you build the query without knowing the unix TimeStamp as
>'1111527115' is the current date ? I am trying to build the query so it
>dynamically know what to look for
>
>like
> SELECT * FROM SessionTable WHERE MONTH(from_unixtime(all available
>records)) = 'March';
>
>is something like this possible ?
>
>many thanks
>g
>
>
>On Mysql (works on 4.0 atleast), you can use the FROM_UNIXTIME() function
>to convert a unix timestamp back to universal date/time format. From then
>on you can use any standard mysql date/time functions to compare the month.
>So your query becomes something like:
>
> SELECT * FROM SessionTable WHERE MONTH(from_unixtime(1111527115)) = 3;
>
>MONTH() returns a numeric month number from 1-12. See the mysql
>documentation on date and time functions here:
>
>http://dev.mysql.com/doc/mysql/en/d...-functions.html
>
>Hope this helps.
>
>On Mar 22, 2005, at 1:35 PM, Bastien Koert wrote:
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
|
|
|
|
|