Re: Confused by to_char

From: Chris Green <chris(at)areti(dot)co(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Confused by to_char
Date: 2005-02-08 13:08:53
Message-ID: 20050208130853.GA21169@areti.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Feb 08, 2005 at 12:28:26PM +0000, mike wrote:
> I am am trying to get a day string from a date using to_char ie:
>
> SELECT date1,ti1 ,to1,ti2,to2,adj,ei,eo,to_char('2005-02-07','Day') FROM
> vw_times_list1
>
> however I get
>
> function to_char("unknown", "unknown") is not unique
>
> (using to_date does not recognise the date format)
>
> anyone any ideas what I am doing wrong
>
Yes, in a way.

to_char needs two parameters, a pattern and a variable to format
according to the pattern. You've given it a pattern it doesn't
recognise and a constant string which doesn't look like a date.

It needs to look something like:-

to_char(date_time, 'RRRRMMDDHH24MISS')

This is an Oracle example so I'm not sure if the pattern is exactly
right but it'll look something like this. Look at the documentation
for to_char() for the format of the pattern. date_time is a date
column in your database.

--
Chris Green (chris(at)areti(dot)co(dot)uk)

"Never ascribe to malice that which can be explained by incompetence."

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Venkatesh Babu 2005-02-08 13:09:02 Re: Update command too slow
Previous Message Ragnar Hafstað 2005-02-08 13:00:56 Re: Confused by to_char