Re: Date Arithmetic in SQL or 4GL
Posted in 2003
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Bulls Eye. Thats what I was looking for. I finally got my code to work using
intervals but that took a long time to search through the documentation.
Not sure if the output is always an interval but when I ran the code below I
got dates as outputs.
MODIFY MODULE >>
DATABASE triptik
DEFINE e_recv_tm DATETIME YEAR TO DAY,
nCount int,
nMonthInt INTERVAL YEAR(2) to MONTH
MAIN
SET ISOLATION TO DIRTY READWHENEVER ANY ERROR STOP
WHENEVER WARNING STOP
LET nMonthInt = '1-06'
LET e_recv_tm = (CURRENT)
LET e_recv_tm = e_recv_tm - nMonthInt
DISPLAY "DATE IS :" , e_recv_tm
"Mark Denham" <mkdenham@comcast.net> wrote in message
news:bhg8t6$fkp$1@terabinaries.xmission.com...
>
> For DATE types:
>
> DEFINE mydate DATE
>
> LET mydate = TODAY - 10 UNITS DAY -- Substract 10 days
> LET mydate = mydate - 100 units MONTH -- You get the idea
>
> Using DATE type variables, you can only add, subtract etc in units of
YEARS,
> MONTHS and DAYS.
>
> You can do similar stuff to DATETIME values. I have never made much use of
> interval values. If memory serves me right, when using interval values the
> resulting value is always an interval.
>
> Mark
>
> ----- Original Message -----
> From: "Jack A" <InformixMail@yahoo.com>
> To: <informix-list@iiug.org>
> Sent: Thursday, August 14, 2003 09:34
> Subject: Date Arithmetic in SQL or 4GL
>
>
> > How is date arithmetic done in informix. I've been reading about an
> > Interval type but cant find a single example. By date arithmetic I
> > mean adding dates and subtracting dates. Which manual would have this
> > information.
> >
> > TIA
>
> sending to informix-list
For DATE types: DEFINE mydate DATE LET mydate = TODAY - 10 UNITS DAY -- Substract 10 days LET mydate = mydate - 100 units MONTH -- You get the idea Using DATE type variables, you can only add, subtract etc in units of YEARS, MONTHS and DAYS. You can do similar stuff to DATETIME values. I have never made much use of interval values. If memory serves me right, when using interval values the resulting value is always an interval. Mark ----- Original Message ----- From: "Jack A" <InformixMail@yahoo.com> To: <informix-list@iiug.org> Sent: Thursday, August 14, 2003 09:34 Subject: Date Arithmetic in SQL or 4GL > How is date arithmetic done in informix. I've been reading about an > Interval type but cant find a single example. By date arithmetic I > mean adding dates and subtracting dates. Which manual would have this > information. > > TIA sending to informix-list