Padding time values from EXTRACT() - Mailing list pgsql-novice

From Mark Kelly
Subject Padding time values from EXTRACT()
Date
Msg-id 200911190015.38074.pgsql@wastedtimes.net
Whole thread Raw
Responses Re: Padding time values from EXTRACT()  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Padding time values from EXTRACT()  (Steve Crawford <scrawford@pinpointresearch.com>)
List pgsql-novice
Hi.

If I use the following snippet

EXTRACT (hour FROM timestamp) || ':' ||
EXTRACT (minute FROM timestamp)
AS this_time

I get single digit figures returned for minutes less than 10, resulting in the
odd-looking 12:5 when I was expecting 12:05.

Actual column value is '2009-11-18 12:05:31.030546', which I why I assumed I'd
get the 0 in the returned value.

Is there any way to zero pad the only the values below 10 so I always get two
character responses for the minutes?

Thanks,

Mark

pgsql-novice by date:

Previous
From: Richard Broersma
Date:
Subject: Re: Introduction
Next
From: Tom Lane
Date:
Subject: Re: Padding time values from EXTRACT()