updating oE subtract


include datetime.e -- (default namespace is datetime) 
public function subtract(datetime dt, atom qty, integer interval) 

Subtracts a number of intervals to a base datetime.

  1. dt : the base datetime
  2. qty : the number of intervals to subtract. It should be positive.
  3. interval : which kind of interval to subtract.

A sequence, more precisely a datetime representing the new moment in time.


Please see Constants for Date and Time for a reference of valid intervals.

See the function add for more information on adding and subtracting date intervals

Example 1:
include std/datetime.e 
datetime dt1 = now() 
? dt1 
datetime dt2 = subtract(dt1, 18, MINUTES) -- subtract 18 minutes from dt1 
? dt2 
dt2 = subtract(dt1, 7, MONTHS)   -- subtract 7 months from dt1 
? dt2 
dt2 = subtract(dt1, 12, HOURS)   -- subtract 12 hours from dt1 
? dt2 

{2019,9,8,3,10,13} (yours will vary)

See Also:

add, diff

Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu