Thread: How to extract hour and minutes from a timestamp
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
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/ ---------------------------------------------------------------------
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