For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > June 2004 > Date Select









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 Date Select
Tom Chubb

2004-06-25, 3:55 pm

How can I query a MySQL table to get the latest results from a date field?
Basically, I am inserting several records at a time at the end of each w.
I want to have a page that displays the results for the last w only.
The date format in the field is YYYY-MM-DD

Torsten Roehr

2004-06-25, 3:55 pm

"Tom Chubb" <tom@ps-promo.co.uk> wrote in message
news:JPEMIHJHEEGAJDFPLGHIKELOEMAA.tom@ps-promo.co.uk...
> How can I query a MySQL table to get the latest results from a date field?
> Basically, I am inserting several records at a time at the end of each

w.
> I want to have a page that displays the results for the last w only.
> The date format in the field is YYYY-MM-DD


Please go to the mysql.com website, search for "date" and you'll find a
detailed description of how to query date columns.

Regards, Torsten Roehr
Pete M

2004-06-25, 3:55 pm

select * from table where w(date_field) = ( w(now()) -1 )

Tom Chubb wrote:
> How can I query a MySQL table to get the latest results from a date field?
> Basically, I am inserting several records at a time at the end of each w.
> I want to have a page that displays the results for the last w only.
> The date format in the field is YYYY-MM-DD
>

Gerben

2004-06-25, 3:55 pm

select * from table where TO_DAYS(date_field) > ( TO_DAYS(NOW()) -7 )

this will give the entries of the last 7 days (and the ones that are in the
future)

"Tom Chubb" <tom@ps-promo.co.uk> wrote in message
news:JPEMIHJHEEGAJDFPLGHIKELOEMAA.tom@ps-promo.co.uk...
> How can I query a MySQL table to get the latest results from a date field?
> Basically, I am inserting several records at a time at the end of each

w.
> I want to have a page that displays the results for the last w only.
> The date format in the field is YYYY-MM-DD
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com