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

Re: dates

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John Ensign <john(at)deepsnow(dot)org>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: dates
Date: 2006-05-17 17:05:31
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
John Ensign <john(at)deepsnow(dot)org> writes:
> select to_date( textfield1, 'MM-DD-YYYY') as startDate, CAST 
> ( textfield2, int4) as duration, startDate + duration as endDate.

That's got at least two problems: one, that's not the syntax of CAST,
you need to write CAST(textfield2 AS int4); and two, you can't reference
a SELECT output column from another column like that.  You could write

    to_date(textfield1, 'MM-DD-YYYY') as startDate,
    CAST(textfield2 AS int4) as duration,
    to_date(textfield1, 'MM-DD-YYYY') + CAST(textfield2 AS int4) as endDate
from whatever ...

			regards, tom lane

In response to

  • dates at 2006-05-17 15:53:32 from John Ensign

pgsql-novice by date

Next:From: Dhruv MataniDate: 2006-05-17 17:35:27
Subject: Where to get more info. about the optimizer?
Previous:From: John EnsignDate: 2006-05-17 15:53:32
Subject: dates

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