[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: dateadd problem



You have to explicitly DECLARE your date variable as a date type item, otherwise
SQR assumes your variable to be of type = character and you will get the
"dateadd" error.

Put this at the top of your program and I think it will resolve your problem.

begin-setup
   declare-variable
      date    $chart_for_date  $chart_thru_date
   end-declare
end-setup

When you do this, you might need to convert the date to a string (DATETOSTR)
before printing it.






Bob Helm <Bob.Helm@MEDIWARE.COM> on 04/05/2001 12:44:30 PM

Please respond to sqr-users@list.iex.net

To:   SQR-USERS@list.iex.net
cc:    (bcc: Rick Creel/IT/Aon Consulting)

Subject:  dateadd problem



I have a problem that should be easy to fix, but I'm stuck.

I simply want to add 2 months to a date. My code is as follows:

let $run_day = edit(Datenow(),'DD')
    if $run_day != '05'
        let $chart_for_date = dateadd(datenow(),'month',1)
        print $chart_for_date (+1,1)  edit 'Month YYYY'
    else
        let $chart_for_date = Datenow()
        print $chart_for_date (+1,1)  edit 'Month YYYY'
    end-if

    let $chart_thru_date = dateadd($chart_for_date,'month',2)
    print $chart_thru_date  (+1,1)

When I try to run I get the following error message:

Error on line 282:
   (SQR 4045) Function or operator 'dateadd' requires date argument.

As you can see, if I use Datenow() for the date value, it works. Otherwise,
I get the error
and am having to write unnecessary lines of code.


Thanks a ton,

B
The Programmer formally known as Bob
Mediware Information Systems Inc.
(913) 307-1045
Bob.Helm@Mediware.com