using between with dates

Started by Geoffrey Myersalmost 16 years ago4 messagesgeneral
Jump to latest
#1Geoffrey Myers
geof@serioustechnology.com

I'm trying the following:

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

But this returns:

ERROR: invalid input syntax for integer: "04/30/2010"

Can I use between with dates?

--
Geoffrey Myers
Myers Consulting Inc.
770.592.1651

#2Thom Brown
thombrown@gmail.com
In reply to: Geoffrey Myers (#1)
Re: using between with dates

On 29 April 2010 14:55, Geoffrey Myers <geof@serioustechnology.com> wrote:

I'm trying the following:

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

But this returns:

ERROR: invalid input syntax for integer: "04/30/2010"

Can I use between with dates?

You need to cast that last date, so:

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

Thom

#3Szymon Guz
mabewlun@gmail.com
In reply to: Geoffrey Myers (#1)
Re: using between with dates

2010/4/29 Geoffrey Myers <geof@serioustechnology.com>

I'm trying the following:

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

But this returns:

ERROR: invalid input syntax for integer: "04/30/2010"

Can I use between with dates?

This should be fine:
ship_date between '04/30/2010'::date AND '04/30/2010'::date + 14

regards
Szymon Guz

#4A. Kretschmer
andreas.kretschmer@schollglas.com
In reply to: Geoffrey Myers (#1)
Re: using between with dates

In response to Geoffrey Myers :

I'm trying the following:

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

But this returns:

ERROR: invalid input syntax for integer: "04/30/2010"

Can I use between with dates?

Sure, why not, but you have to CAST your STRING into a DATE, or you have
to use to_date().

test=*# select '04/30/2010'::date;
date
------------
2010-04-30
(1 row)

And yes, write "+ '14 days'::interval " instead of just only +14.

Regards, Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 389D 1DC2 3172 0C99