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_s chedule.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 1234
* 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)
iD8DBQFBYrMlrzg MPqB3kigRAp4KAJ 9XlP5rkLOk6d4zm 5U5R+fXJxRw3ACe LoEH
7lyDhCDLf+e+AS8 F95PLYYo=
=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_s chedule.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_s chedule.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_s chedule.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(tim e) 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_s chedule.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***@planetarg on.com
* 503.351.4730 | blog.planetargo n.com
* PHP/PostgreSQL Hosting & Development
*************** *************** **********/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQBBYraO0Qa QZBaqXgwRAkNMAJ 0dYCowvc0k42puC 2tP+KYUdZ0hSwCe LVRQ
EPqNgF0zbXg6V4q TmPjJLwQ=
=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*******@postg resql.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 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 legit, it's just an opt-in mailing.
I have a feeling that using a 'while' loop with repeated calls to
mail() is not the best practice. Is there...
|
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 list behaviour where emails are sent
to a particular address (like mailinglist@mydomain.com) and then distributed
to all of the email addresses?.
...
|
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 newbie's not trying to
follow ESR's advice.)
A month or so ago (in a thread found here: http://tinyurl.com/5bj8j), I
suggested that it might help the...
|
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 can make it an interesting place.
Ever since Justin "promoted" me to French advocacy contact I received
several requests for information from...
|
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. Also, I am using a "Report Header" to
show a count of how many total labels that are being printed.
Now, my problem is that without the "Report...
| |
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 (checkout.aspx) has customer mailing address, details of
the shopping item, the total amount and an order no. I have this Component
One button here on...
|
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 execute a MailMerge to create mailing labels or
customized letters.
A label name known to MS Word MailMerge mailing label wizard may be used or
a...
|
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 already gated to Google Groups and a
small number of private news servers. If Mike Cox
succeeds, this list will be available as a newsgroup
on a great...
|
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 send Mail
Please suggest me how to send these personalised newsletter... through
PHP
|
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 - address,city, postal code
and other one is mailing address which is populated automatically if a check box is checked "Is mailing address same" -...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |