Xbasic

*add_minutes Function

Syntax

dim newTime as T = *ADD_MINUTES(time as T, minutes as N)

Arguments

timeTime

A time value.

minutesNumeric

The number of minutes to add to the time value. Minutes can be a negative value.

Returns

newTimeTime

Returns the time value incremented by minutes.

Description

Add minutes to date or time.

Discussion

The *add_minutes() function increments a time value by a specified number of minutes.

Example

dim time as t
time = now()
? time
= 10/12/2017 08:54:05 89 am

dim minutes as n
minutes = round(rand()*100,0)
? minutes
= 99

? *add_minutes(time, minutes)
= 10/12/2017 10:33:05 89 am

Example: Ajax Callback in a UX

The example below is an Ajax Callback for a UX Component with 3 text boxes with a T (time) type. The callback calculates two reminders based on the time value in the 'ScheduledTime' control. The resulting reminder values are set in the 'Reminder1' and 'Reminder2' text controls in the UX.

function calculateReminders as c (e as p)
    ' Get the submitted time value:
    dim time as T = convert_type(e.dataSubmitted.ScheduledTime,"T")

    ' Compute the time for the 2 reminders: 15 and 30 minutes prior:
    dim reminder1 as T = *add_minutes(time,-30)
    dim reminder2 as T = *add_minutes(time,-15)

    ' Set the value for the reminder textboxes in the UX
    ' Note: Must convert the time value to a string with the format
    ' matching the time format used in the controls.
    e._set.reminder1.value = time("MM/dd/yyyy 0h:0m am",reminder1)
    e._set.reminder2.value = time("MM/dd/yyyy 0h:0m am",reminder2)

    ' Return optional JavaScript here:
    calculateReminders = ""
end function

See Also