Re: using between with dates

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Geoffrey <lists(at)serioustechnology(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: using between with dates
Date: 2010-04-29 14:16:03
Message-ID: 11098.1272550563@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Geoffrey <lists(at)serioustechnology(dot)com> writes:
> ship_date between '04/30/2010' AND '04/30/2010' + 14
> ERROR: invalid input syntax for integer: "04/30/2010"

> Can I use between with dates?

The problem with that is the parser has no reason to treat the strings
as dates, at least not till it comes to consider the BETWEEN
comparisons, which is too late to help in resolving the addition
in the subexpression (data types are determined bottom-up).
This'd work:

ship_date between '04/30/2010' AND '04/30/2010'::date + 14

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Geoffrey 2010-04-29 14:26:35 Re: using between with dates
Previous Message sandeep prakash dhumale 2010-04-29 14:14:10 Re: Re: [GENERAL] [SQL] Tsearch not searching 'Y'