pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedFormatting current_time output
6+ messages / 5 participants
[nested] [flat]
* Formatting current_time output
@ 2002-10-03 14:46 Thomas Good <tomg@sqlclinic.net>
0 siblings, 2 replies; 6+ messages in thread
From: Thomas Good @ 2002-10-03 14:46 UTC (permalink / raw)
To: pgsql-sql
Hi.
Anyone have any tips on how I can approximate the following:
SELECT TO_CHAR(SYSDATE,'HH:MI AM') FROM DUAL; -- Oracle
SELECT TIME_FORMAT(current_time,'%l:%i %p'); -- MySQL
Returned: 10:58 AM
I've found lpad(current_time,5); which gets me 1/3 of the way.
Is there a function I haven't found?
TIA
-----------------------------------------------------------------------
Thomas Good e-mail: tomg@sqlclinic.net
Programmer/Analyst phone: (+1) 718.818.5528
Residential Services fax: (+1) 718.818.5056
Behavioral Health Services, SVCMC-NY mobile: (+1) 917.282.7359
-- --
SQL Clinic - An Open Source Clinical Record www.sqlclinic.net
------------------------------------------------------------------------
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Formatting current_time output
@ 2002-10-03 15:03 Josh Berkus <josh@agliodbs.com>
parent: Thomas Good <tomg@sqlclinic.net>
1 sibling, 3 replies; 6+ messages in thread
From: Josh Berkus @ 2002-10-03 15:03 UTC (permalink / raw)
To: Thomas Good <tomg@sqlclinic.net>; pgsql-sql
Thomas,
> SELECT TO_CHAR(SYSDATE,'HH:MI AM') FROM DUAL; -- Oracle
> SELECT TIME_FORMAT(current_time,'%l:%i %p'); -- MySQL
>
> Returned: 10:58 AM
>
> I've found lpad(current_time,5); which gets me 1/3 of the way.
> Is there a function I haven't found?
Um, what's wrong with:
SELECT to_char(current_time, 'HH12:MI AM');
?
(See "Formatting Functions" under "Functions and Operators" in the
User's Guide)
-Josh Berkus
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Formatting current_time output
@ 2002-10-03 15:10 Thomas Good <tomg@sqlclinic.net>
parent: Josh Berkus <josh@agliodbs.com>
2 siblings, 0 replies; 6+ messages in thread
From: Thomas Good @ 2002-10-03 15:10 UTC (permalink / raw)
To: Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-sql
On Thu, 3 Oct 2002, Josh Berkus wrote:
> Thomas,
>
> > SELECT TO_CHAR(SYSDATE,'HH:MI AM') FROM DUAL; -- Oracle
> > SELECT TIME_FORMAT(current_time,'%l:%i %p'); -- MySQL
> >
> > Returned: 10:58 AM
> >
> > I've found lpad(current_time,5); which gets me 1/3 of the way.
> > Is there a function I haven't found?
>
> Um, what's wrong with:
> SELECT to_char(current_time, 'HH12:MI AM');
Not a thing! Except that I think you mean 'current_date'. ;-)
Cheers Josh (and thanks alot)...
BTW the JOIN you sent the other day worked fine.
Thanks again,
-----------------------------------------------------------------------
Thomas Good e-mail: tomg@sqlclinic.net
Programmer/Analyst phone: (+1) 718.818.5528
Residential Services fax: (+1) 718.818.5056
Behavioral Health Services, SVCMC-NY mobile: (+1) 917.282.7359
-- --
SQL Clinic - An Open Source Clinical Record www.sqlclinic.net
------------------------------------------------------------------------
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Formatting current_time output
@ 2002-10-03 15:22 Charles H. Woloszynski <chw@clearmetrix.com>
parent: Josh Berkus <josh@agliodbs.com>
2 siblings, 0 replies; 6+ messages in thread
From: Charles H. Woloszynski @ 2002-10-03 15:22 UTC (permalink / raw)
To: Josh Berkus <josh@agliodbs.com>; +Cc: Thomas Good <tomg@sqlclinic.net>; pgsql-sql
On 7.2.2, you can use
select to_char(now(), 'HH12:MI AM');
(using current_time raises an error, but now() works fine).
Charlie
Josh Berkus wrote:
>Thomas,
>
>
>
>>SELECT TO_CHAR(SYSDATE,'HH:MI AM') FROM DUAL; -- Oracle
>>SELECT TIME_FORMAT(current_time,'%l:%i %p'); -- MySQL
>>
>>Returned: 10:58 AM
>>
>>I've found lpad(current_time,5); which gets me 1/3 of the way.
>>Is there a function I haven't found?
>>
>>
>
>Um, what's wrong with:
>SELECT to_char(current_time, 'HH12:MI AM');
>?
>
>(See "Formatting Functions" under "Functions and Operators" in the
>User's Guide)
>
>-Josh Berkus
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
>http://www.postgresql.org/users-lounge/docs/faq.html
>
>
--
Charles H. Woloszynski
ClearMetrix, Inc.
115 Research Drive
Bethlehem, PA 18015
tel: 610-419-2210 x400
fax: 240-371-3256
web: www.clearmetrix.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Formatting current_time output
@ 2002-10-03 15:28 Karel Zak <zakkr@zf.jcu.cz>
parent: Thomas Good <tomg@sqlclinic.net>
1 sibling, 0 replies; 6+ messages in thread
From: Karel Zak @ 2002-10-03 15:28 UTC (permalink / raw)
To: Thomas Good <tomg@sqlclinic.net>; +Cc: pgsql-sql
On Thu, Oct 03, 2002 at 10:46:19AM -0400, Thomas Good wrote:
>
> SELECT TO_CHAR(SYSDATE,'HH:MI AM') FROM DUAL; -- Oracle
> SELECT TIME_FORMAT(current_time,'%l:%i %p'); -- MySQL
SELECT TO_CHAR(now(),'HH:MI AM'); -- PostgreSQL
:-)
--
Karel Zak <zakkr@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/
C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Formatting current_time output
@ 2002-10-03 15:28 Achilleus Mantzios <achill@matrix.gatewaynet.com>
parent: Josh Berkus <josh@agliodbs.com>
2 siblings, 0 replies; 6+ messages in thread
From: Achilleus Mantzios @ 2002-10-03 15:28 UTC (permalink / raw)
To: Josh Berkus <josh@agliodbs.com>; +Cc: Thomas Good <tomg@sqlclinic.net>; pgsql-sql
SELECT to_char(now(), 'HH24:MI AM');
(in 7.2.1)
==================================================================
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel: +30-10-8981112
fax: +30-10-8981877
email: achill@matrix.gatewaynet.com
mantzios@softlab.ece.ntua.gr
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2002-10-03 15:28 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-10-03 14:46 Formatting current_time output Thomas Good <tomg@sqlclinic.net>
2002-10-03 15:03 ` Josh Berkus <josh@agliodbs.com>
2002-10-03 15:10 ` Thomas Good <tomg@sqlclinic.net>
2002-10-03 15:22 ` Charles H. Woloszynski <chw@clearmetrix.com>
2002-10-03 15:28 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
2002-10-03 15:28 ` Karel Zak <zakkr@zf.jcu.cz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox