Re: Date arithmetic in Informix Online 5.0
Posted in 2000
Topics: Installation, Setup & Upgrades
From: Zack Hamm <zhamm@nc.rr.com>
>
>I'm trying to do some basic date math in informix online. I have a
>table with a column called 'access_date' which has a date column stored
>as '20000702' for todays date. I'd like to be able to generate queries
>where I can say "look at all events which have happened XX days from
>today". (e.g. 20000702-90 would be 3 months ago)
>I know in mysql there is a command called DATE_SUB which does this, is
>there an equivalent in informix, particularly in Online version 5? (I
>know, I know, it's an OLD version, but the customer won't upgrade).
Well, what happens when you say
SELECT *
FROM foo
WHERE bar_date = TODAY - 90
?
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
You may want to put parenthesis around the TODAY - 90 to insure it does the
math
before the select. Should you want to get all records from (today-30) and
the present
I suggest you use the BETWEEN clause in your select statement. Just
answering the
next logical question...
Rob Vorbroker
Obnoxio The Clown <obnoxio@hotmail.com> wrote in message
news:8jpi33$9rb$1@news.xmission.com...
>
> From: Zack Hamm <zhamm@nc.rr.com>
> >
> >I'm trying to do some basic date math in informix online. I have a
> >table with a column called 'access_date' which has a date column stored
> >as '20000702' for todays date. I'd like to be able to generate queries
> >where I can say "look at all events which have happened XX days from
> >today". (e.g. 20000702-90 would be 3 months ago)
> >I know in mysql there is a command called DATE_SUB which does this, is
> >there an equivalent in informix, particularly in Online version 5? (I
> >know, I know, it's an OLD version, but the customer won't upgrade).
>
> Well, what happens when you say
>
> SELECT *
> FROM foo
> WHERE bar_date = TODAY - 90>
> ?
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>