Обсуждение: compare month

Поиск
Список
Период
Сортировка

compare month

От
shakil tanvir
Дата:
Hi all of you PostGreSQL fans,

I need to run a query like

SELECT users from userlog where lastlogindate is less than one month
or
SELECT users from userlog where lastlogindate is less than 15 days

Can any one help with sql example?

Shakil
tanvirshakil@yahoo.com


Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.

Re: compare month

От
"A. Kretschmer"
Дата:
am  03.04.2006, um 23:58:50 -0700 mailte shakil tanvir folgendes:
> Hi all of you PostGreSQL fans,
>
> I need to run a query like
>
> SELECT users from userlog where lastlogindate is less than one month
> or
> SELECT users from userlog where lastlogindate is less than 15 days
>
> Can any one help with sql example?

Hey, read my answer in #postgresql ;-)

08:48 < shakil> i neeed to compare days in sql query like "SELECT users from userlog where lastLoginDate is 7 days old"
08:48 < shakil> can any one help?
08:49 < shakil> or SELECT users from userlog where lastLoginDate is one month old
08:51 < akretschmer> shakil: select .... where lastLoginDate > current_date - '7days'::interval
08:51 < akretschmer> shakil: you can also use '1month'::interval


HTH, Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47215,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===

Re: compare month

От
Michael Glaesemann
Дата:
Hi!

On Apr 4, 2006, at 15:58 , shakil tanvir wrote:

> Hi all of you PostGreSQL fans,

True fans spell it PostgreSQL :)

> SELECT users from userlog where lastlogindate is less than one month
> or

select users
from userlog
where lastlogindate > current_timestamp - 1 * interval '1 month';


> SELECT users from userlog where lastlogindate is less than 15 days

select users
from userlog
where lastlogindate > current_timestamp - 15 * interval '1 day';

You can also use current_date instead of current_timestamp, depending
on your desired data type.

Hope this helps!

Michael Glaesemann
grzm myrealbox com




Re: compare month

От
Kaloyan Iliev
Дата:
Hi,
SELECT users from userlog where lastlogindate > CURRENT_DATE-'1
month'::interval;
or
SELECT users from userlog where lastlogindate > CURRENT_DATE-'15
days'::interval;


I think this will work for you.

Have a nice day


shakil tanvir wrote:

> Hi all of you PostGreSQL fans,
>
> I need to run a query like
>
> SELECT users from userlog where lastlogindate is less than one month
> or
> SELECT users from userlog where lastlogindate is less than 15 days
>
> Can any one help with sql example?
>
> Shakil
> tanvirshakil@yahoo.com
>
> ------------------------------------------------------------------------
> Yahoo! Messenger with Voice.
> <http://us.rd.yahoo.com/mail_us/taglines/postman3/*http://us.rd.yahoo.com/evt=39666/*http://beta.messenger.yahoo.com>

> PC-to-Phone calls for ridiculously low rates.