datetime - datetime = interval but it is always null
Posted in 1996
Topics: Stored Procedures & SPL
I am trying to compare the expiration date of a unit of inventory with the location I would like to put it in. If there is more than 60 months difference I want to put it somewhere else. Take a look at this sample code: database blah main define s_date datetime year to minute define e_date datetime year to minute define c_date datetime year to minute define cur_time datetime hour to fraction(3) define exp_int interval year (4) to month define num_int integer define dt_str char(80) define i integer define j integer let s_date = "2015-11-11 00:00" let e_date = "2022-11-10 00:00" let c_date = "1998-09-28 00:00" let cur_time = current display "s_date :", s_date display "e_date :", e_date display "c_date :", c_date let exp_int = (e_date - s_date) if exp_int is not null ## I think it is always null then display "it is not null" end if let num_int = exp_int let dt_str = exp_int display "Interval is: ", exp_int using " ###", "-", num_int, "-",dt_str --if (s_date > "2015-01-01 00:00" ## This works ok but YUK --and e_date > "2015-01-01 00:00") if ((e_date - s_date) < 60 units month) ## The interval never fits then display "Interval fit" else display "Interval did not fit" end if end main I would hate to hard code the dates in and it requires more programming. HELP!! Thanks in advance