Hello-
I am in the process of translating a site using mysql as the backend
over to postgres. I have a lot of time data that I would like to
display to the user in the form of a schedule.
I am using the to_char function to make the times human friendly
to_char(class_schedule.endtime, 'HH:MI:SS AM')
which returns
06:30:00 AM - 07:30:00 AM
I am really looking to get it outputting like this.
6:30 AM - 7:30 AM
I have looked through the documentation and haven't found anything to
do this in postgres. I am going to have to do this formating in the
application layer?
Thanks
Todd Marek
"If you think you understand something it's habit."
--Gary Kraftsow-- 10 1223
* Todd P Marek (af****@somahq.com) wrote: I have looked through the documentation and haven't found anything to do this in postgres. I am going to have to do this formating in the application layer?
If nothing else I'd think you could create your own function in Postgres
to display the time however you like it.. Someone may have a better
suggestion, but I wouldn't expect that to be very difficult.
Stephen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBYrMlrzgMPqB3kigRAp4KAJ9XlP5rkLOk6d4zm5U5R+ fXJxRw3ACeLoEH
7lyDhCDLf+e+AS8F95PLYYo=
=qdIW
-----END PGP SIGNATURE-----
I would thought it would be an obvious try:
cnagy=> select to_char(now(), 'HH:MM AM');
to_char
----------
04:10 PM
(1 row)
HTH,
Csaba.
On Tue, 2004-10-05 at 16:32, Todd P Marek wrote: Hello-
I am in the process of translating a site using mysql as the backendover to postgres. I have a lot of time data that I would like todisplay to the user in the form of a schedule.
I am using the to_char function to make the times human friendly
to_char(class_schedule.endtime, 'HH:MI:SS AM')
which returns
06:30:00 AM - 07:30:00 AM
I am really looking to get it outputting like this.
6:30 AM - 7:30 AM
I have looked through the documentation andhaven't found anything to do this in postgres. I am going to have todo this formating in the application layer?
Thanks Todd Marek
"If you think you understand somethingit's habit." --Gary Kraftsow--
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Todd P Marek <af****@somahq.com> writes: I am using the to_char function to make the times human friendly to_char(class_schedule.endtime, 'HH:MI:SS AM') which returns 06:30:00 AM - 07:30:00 AM
I am really looking to get it outputting like this. 6:30 AM - 7:30 AM
I have looked through the documentation and haven't found anything to do this in postgres.
I think you want 'FMHH:MI AM' ... if not, you'd better be more specific
about what you want.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives? http://archives.postgresql.org
On Tue, 5 Oct 2004, Todd P Marek wrote: Hello-
I am in the process of translating a site using mysql as the backend over to postgres. I have a lot of time data that I would like to display to the user in the form of a schedule.
I am using the to_char function to make the times human friendly
to_char(class_schedule.endtime, 'HH:MI:SS AM')
which returns
06:30:00 AM - 07:30:00 AM
I am really looking to get it outputting like this.
6:30 AM - 7:30 AM
For the seconds, do you want seconds if it's not 00, or do you just not
want seconds at all? Because removing :SS will get rid of the seconds
display.
For the leading 0s, you'd probably need to do a user defined function to
trim them off, but it'd probably be relatively simple use of ltrim, so you
might do something like:
create function format_time(time) returns text as '
select ltrim(to_char($1, ''HH:MI AM''), ''0'')' language 'sql';
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
On Tue, 2004-10-05 at 09:32 -0500, Todd P Marek wrote: __________________________________________________ ____________________ Hello- I am in the process of translating a site using mysql as the backend over to postgres. I have a lot of time data that I would like to display to the user in the form of a schedule. I am using the to_char function to make the times human friendly to_char(class_schedule.endtime, 'HH:MI:SS AM') which returns 06:30:00 AM - 07:30:00 AM I am really looking to get it outputting like this. 6:30 AM - 7:30 AM
Yeah, you're getting exactly what you're asking PostgreSQL to give you.
Drop the ':SS' if you don't want the seconds.
You can find out more about how you can format your date/times here: http://www.postgresql.org/docs/curre...tic/functions-
formatting.html#FUNCTIONS-FORMATTING-DATETIME-TABLE
Good luck,
Robby
--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON | www.planetargon.com
* Portland, OR | ro***@planetargon.com
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
****************************************/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQBBYraO0QaQZBaqXgwRAkNMAJ0dYCowvc0k42puC2tP+K YUdZ0hSwCeLVRQ
EPqNgF0zbXg6V4qTmPjJLwQ=
=TM6S
-----END PGP SIGNATURE-----
SELECT trim(leading '0' from to_char(now(), 'HH:MM AM'))
I think is what you really want. This gets rid of the nasty leasing 0.
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
On Oct 5, 2004, at 10:00 AM, Kevin Barnard wrote: SELECT trim(leading '0' from to_char(now(), 'HH:MM AM'))
I think is what you really want. This gets rid of the nasty leasing 0.
I wasn't even paying attention to the seconds. I was in fact talking
about the leading 0.
Thanks to everyone and apologies for my oversight of the seconds clause.
Todd Marek
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly
Hey, I didn't know "trim" is so flexible... cool !
Cheers,
Csaba.
On Tue, 2004-10-05 at 17:00, Kevin Barnard wrote: SELECT trim(leading '0' from to_char(now(), 'HH:MM AM'))
I think is what you really want. This gets rid of the nasty leasing 0.
---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
Going back to the documents I think Tom's answer of prepending FM is
better then mine. Look at table 9-22 for other options
On Tue, 5 Oct 2004 10:06:51 -0500, Todd P Marek <af****@somahq.com> wrote:
On Oct 5, 2004, at 10:00 AM, Kevin Barnard wrote:
SELECT trim(leading '0' from to_char(now(), 'HH:MM AM'))
I think is what you really want. This gets rid of the nasty leasing 0.
I wasn't even paying attention to the seconds. I was in fact talking about the leading 0.
Thanks to everyone and apologies for my oversight of the seconds clause.
Todd Marek
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
On Tue, Oct 05, 2004 at 10:00:29 -0500,
Kevin Barnard <ke***********@gmail.com> wrote: SELECT trim(leading '0' from to_char(now(), 'HH:MM AM'))
I think is what you really want. This gets rid of the nasty leasing 0.
Won't that be a problem for times between 0000 and 0059?
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives? http://archives.postgresql.org This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Thom McGrath |
last post by:
I'm writing a simple mailing list program, and I would like to know
what the suggested method of sending a large number of emails to a list
of addresses. (sounds like spam, no?)
It's perfectly...
|
by: Dave Moore |
last post by:
Hi All,
Is it possible to implement a mailing list using PHP?. I know I could
maintain a list of emails addresses in a db and send mail to them through my
website, but how can I get true mailing...
|
by: Brian van den Broek |
last post by:
Hi all,
There have been a few posts over the last month or so expressing a bit
of exasperation with the "rising tide of newbie's". (Or, more
accurately, the rising tide of questions from...
|
by: Francois Suter |
last post by:
To all French speakers on the list,
I am pleased to announce the start of a PostgreSQL general mailing list
in French. Its name is pgsql-fr-generale. I hope many of you will join
it so that we...
|
by: Grim Reaper |
last post by:
I know this is probably an easy question, but I could not find/figure it
out.
Basically, I am printing mailing labels with a "Sorting/Grouping" section
that groups the label types together....
| |
by: sameer |
last post by:
Hi,
Steve i been trying to use this component paypay control which is really
easy and excellent but this is what i think is the limitation and i just can
not be done with.
My checkout page...
|
by: Mikey |
last post by:
Sample VB .NET source code to create mailing labels or customized letters
using MS Word MailMerge
This VB .NET source code will start MS Word and call methods and set
properties in MS Word to...
|
by: Andy M |
last post by:
ALERT
There is a person by the name of Mike Cox who's trying
to turn this mailing list into a Big-8 newsgroup. Many
of you know that this and most of the other postresql
mailing lists are...
|
by: cordial_camaraderie |
last post by:
I need to send 30,000 emails to our NewsLetter Subscriber,
I tried to use our hosting Site and for the worst part We we banned and
our site was stopped.
I am using PHP script, mail() function to...
|
by: razjafry |
last post by:
Hi Experts,
I have two tables - tblContact and tblOrg
Contact table has only one option of mailing address e.g address,city,postal code
whereas Org table has two options - one simple address -...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |