Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB2 Timestamp or current date 1

Status
Not open for further replies.

deacon1945

Programmer
Oct 8, 2003
1
US
I need to calculate a date in DB2 and I know I can do it like this:
EXEC SQL
SET :HOLD-TIMESTAMP =
CURRENT TIMESTAMP - 18 MONTHS
END-EXEC.
or
EXEC SQL
SET :HOLD-TIMESTAMP =
CURRENT TIMESTAMP - 20 DAYS
END-EXEC.
What I would like to do is have a variable to hole the numbers; this would add to the versatility and eliminate the need to change it when a client wanted a different date.

Thanks in advance for the help.

 
deacon1945,

you simply need to do as follows

EXEC SQL
SET :HOLD-TIMESTAMP =
CURRENT TIMESTAMP - :wc-number DAYS
END-EXEC.

Where wc-number is a host variable. If in Cobol the definition I would use for wc-number would be s9(15) comp-3.

Cheers
Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top