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

Re: Passing Date Parameters (the answer)



Shortly after I sent the message below I figured out the answer to my own
problem.  The answer follows for any who are interested.

If the procedure 'Tomorrow' in Snippet #1 is changed to:

begin-procedure Tomorrow(:$T_D)
    declare-variable
        date $T_D
    end-declare
    let $T_D = DateAdd($T_D, 'DAY', 1)
end-procedure

then $T_D becomes a DATE.

Jim Womeldorf
Programmer/Analyst
Fastenal Company
jwomeldo@fastenal.com
(507) 453-8250


-----Original Message-----
From: James Womeldorf
Sent: Saturday, March 03, 2001 5:13 AM
To: SQR-USERS@list.iex.net
Subject: Passing Date Parameters


I am trying to develop a procedure that performs some operations with date
fields.  This procedure may eventually be placed in an include file.  I am
not a very big fan of global variables (especially in include files) as they
are difficult to keep track of, so I want to pass these dates in and out
using parameters.

Here are two code snippets to demonstrate my question:

############################################################################
##########
Snippet #1    (Does not work)
*******************************************************
begin-setup
    declare-variable
        date $FROM_DATE
    end-declare
end-setup

Begin-Program
    let $FROM_DATE = datenow()
    show $FROM_DATE
    do Tomorrow($FROM_DATE)
    show $FROM_DATE
End-Program

begin-procedure Tomorrow(:$T_D)
    let $T_D = DateAdd($T_D, 'DAY', 1)        !error refers to this line
end-procedure

This code generates the following error:
(SQR 4045) Function or operator 'dateadd' requires date argument.

############################################################################
##########
Snippet #2    (This one works)
*******************************************************
begin-setup
    declare-variable
        date $FROM_DATE
    end-declare
end-setup

Begin-Program
    let $FROM_DATE = datenow()
    show $FROM_DATE
    do Tomorrow($FROM_DATE)
    show $FROM_DATE
End-Program

begin-procedure Tomorrow(:$T_D)
    declare-variable
        date $TempDate
    end-declare
    let $TempDate = $T_D
    let $T_D = DateAdd($TempDate, 'DAY', 1)
end-procedure

############################################################################
##########

The Question (Finally!)
Is there any method of specifying that a procedure parameter is of DATE type
specifically so this workaround is not necessary?



Jim Womeldorf
Programmer/Analyst
Fastenal Company
jwomeldo@fastenal.com