Re: How to extract hour and minutes from a timestamp

Lists: pgsql-novice
From: Tan ga <gndtanga(at)mail(dot)pt>
To: pgsql-novice(at)postgresql(dot)org
Subject: How to extract hour and minutes from a timestamp
Date: 2002-10-17 16:52:05
Message-ID: 20021017175001.5E5AB47590C@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Hi again :)

I already resolver my other problem but now i would like to extract both
time and hour from a timestamp in order to compare with a string.
Ex 2000-01-01 19:30:00
I want the result to be 19:30

With select substr(....) i can do this but that's not what i want.

I'm using python with postgres.
--
10Mb na sua caixa de email gratuita no mail.pt
http://www.mail.pt


From: Andrew McMillan <andrew(at)catalyst(dot)net(dot)nz>
To: Tan ga <gndtanga(at)mail(dot)pt>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to extract hour and minutes from a timestamp
Date: 2002-10-17 19:34:19
Message-ID: 1034883258.1154.901.camel@kant.mcmillan.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Fri, 2002-10-18 at 05:52, Tan ga wrote:
> Hi again :)
>
> I already resolver my other problem but now i would like to extract both
> time and hour from a timestamp in order to compare with a string.
> Ex 2000-01-01 19:30:00
> I want the result to be 19:30
>
> With select substr(....) i can do this but that's not what i want.
>
> I'm using python with postgres.

See:
http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/functions-formatting.html

Something like:

to_char( my.timestamp, 'YYYY-MM-DD HH24:MI')

Cheers,
Andrew.
--
---------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267
Survey for free with http://survey.net.nz/
---------------------------------------------------------------------


From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: Tan ga <gndtanga(at)mail(dot)pt>, pgsql-novice(at)postgresql(dot)org
Subject: Re: How to extract hour and minutes from a timestamp
Date: 2002-10-17 19:37:59
Message-ID: web-1790252@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Tan ga,

> I already resolver my other problem but now i would like to extract
> both
> time and hour from a timestamp in order to compare with a string.
> Ex 2000-01-01 19:30:00
> I want the result to be 19:30

Check out "Functions and Operators" in the online user manual.

What you want is:

SELECT to_char(some_timestamp, 'HH:MI');

-Josh Berkus