Обсуждение: Date help
Hi List, This should be simple but though reading the doc's can't figure it out - I'm hopeless at intrepreting documentation. I just want to extract from a table containing entries with dates, all entries from within a specified interval eg last month, or last 10 days. Any help appreciated. Richard
> Hi List, > > This should be simple but though reading the doc's can't figure it out - I'm > hopeless at intrepreting documentation. > > I just want to extract from a table containing entries with dates, all entries > from within a specified interval eg last month, or last 10 days. > > Any help appreciated. > > Richard Your post isn't the clearest, but there are a few ways of accomplishing this. Probably the easiest is: ...WHERE date_field>=(CURRENT_DATE-INTERVAL '10 days') ...WHERE date_field>=(CURRENT_DATE-INTERVAL '1 month') And so on.
On Tuesday 05 October 2010 13:49:41 Garrett Murphy wrote: > WHERE date_field>=(CURRENT_DATE-INTERVAL '1 month') > thanks for the suggestion, I'll take a look tonight about this and get back to the list. richard
There is another way but it might affect the performance: WHERE <date_field> BETWEEN <past_date> AND Now() / CURRENT_DATE; 2010/10/5 richard terry <rterry@pacific.net.au>: > On Tuesday 05 October 2010 13:49:41 Garrett Murphy wrote: >> WHERE date_field>=(CURRENT_DATE-INTERVAL '1 month') >> > thanks for the suggestion, I'll take a look tonight about this and get back to > the list. > > richard > > -- > Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-novice > -- Łukasz Brodziak II MU Bioinformatyka