Skip site navigation (1) Skip section navigation (2)

Re: Date format

From: "Phillip Smith" <phillips(at)weatherbeeta(dot)com(dot)au>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Date format
Date: 2006-07-31 06:45:48
Message-ID: 00f201c6b46c$f53b2700$9b0014ac@ITPhil (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
If you are using PHP, then as Michael mentioned, you can either use the
Postgres to_char function to return the date formatted in the SQL query, or
use the PHP date() function to format it. Eg:

	to_char('01-07-2005', Day, DD Month YYYY') AS "Date"
	Friday   , 01 July       2005

	date('L, d F Y', mktime(0, 0, 0, 07, 01, 2005))
	Friday, 01 July 2005

Note the extra spaces in the SQL version. They are padded out to the maximum
possible length of that string - ie, Friday is padded out to the number of
characters in 'Wednesday' - That's my understanding anyway; Someone care to
correct me?


-----Original Message-----
From: pgsql-novice-owner(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org] On Behalf Of Dylan
Sent: Monday, 31 July 2006 15:23
To: pgsql-novice(at)postgresql(dot)org
Subject: [NOVICE] Date format


I have two fields of column type 'date' from which I want to output a 
formatted date (with PHP).

I understand that MySQL  would use DATE_FORMAT and appropriate %M, %D 
I am having trouble finding the equivalent PostgresQL commands. I am 
using PG 7.3.4.

I have found the template patterns for the conversions. I want it to be 
in this format:

Day, DD Month YYYY

I do not know the function to format this so.

if to_date() converts a string to date, what converts/formats date to 

Thankyou very much.

-Dylan Fogarty-MacDonald

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?


*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to
the addressee.  If you are not the addressee indicated in this message or
responsible for delivery of the message to such person, you may not copy
or deliver this message to anyone, and you should destroy it and kindly
notify the sender by reply email.

Information in this message that does not relate to the official business
of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta.
Weatherbeeta, its employees, contractors or associates shall not be liable
for direct, indirect or consequential loss arising from transmission of this
message or any attachments

In response to

  • Date format at 2006-07-31 05:23:26 from Dylan Fogarty-MacDonald


pgsql-novice by date

Next:From: Dylan Fogarty-MacDonaldDate: 2006-07-31 08:17:57
Subject: Re: Date format
Previous:From: Michael GlaesemannDate: 2006-07-31 05:41:24
Subject: Re: Date format

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group