I want to add 'n' number of minutes to a datetime field. Following code works fine in 4GL.
database rntdb
MAIN
DEFINE c_time DATETIME YEAR TO SECOND
LET c_time="2002-07-28 23:40:40"
DISPLAY c_time
LET c_time=c_time + INTERVAL(46) MINUTE TO MINUTE
DISPLAY c_time
END MAIN
Result:
2002-07-28 23:40:40
2002-07-29 00:26:40
To make this bit of code re-usable and make it dynamic by putting it in a function, results in a disaster. (compilation error)
FUNCTION add_minute(l_units)
DEFINE c_time DATETIME YEAR TO SECOND, l_units smallint
LET c_time="2002-07-28 23:40:40"
DISPLAY c_time
LET c_time=c_time + INTERVAL(l_units) MINUTE TO MINUTE
DISPLAY c_time
END FUNCTION
Compilation time error message:
Non-numeric character in datetime or interval.
See error number -1262.
Would anybody tell me how to solve my requirement using INTERVAL ?
thanks.
shriyan
database rntdb
MAIN
DEFINE c_time DATETIME YEAR TO SECOND
LET c_time="2002-07-28 23:40:40"
DISPLAY c_time
LET c_time=c_time + INTERVAL(46) MINUTE TO MINUTE
DISPLAY c_time
END MAIN
Result:
2002-07-28 23:40:40
2002-07-29 00:26:40
To make this bit of code re-usable and make it dynamic by putting it in a function, results in a disaster. (compilation error)
FUNCTION add_minute(l_units)
DEFINE c_time DATETIME YEAR TO SECOND, l_units smallint
LET c_time="2002-07-28 23:40:40"
DISPLAY c_time
LET c_time=c_time + INTERVAL(l_units) MINUTE TO MINUTE
DISPLAY c_time
END FUNCTION
Compilation time error message:
Non-numeric character in datetime or interval.
See error number -1262.
Would anybody tell me how to solve my requirement using INTERVAL ?
thanks.
shriyan