Salesforce

How Do I Increment the Value of Date-Time Combined Variables? (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Increment the Value of Date-Time Combined Variables? (Magic xpa 3.x)

Adding an amount to a date-time variable can be a lot of work. For instance, suppose you are trying to determine the clock-out time for a worker who started work at 22:00:00. If you add 8 hours to the time, you also need to make sure to increment the date.

Fortunately, Magic xpa provides a function to treat the date and time as one unit. The AddDateTime() function allows you to add or subtract an amount from each of the parts of the date and time (years, months, days, hours, minutes, seconds) but automatically handles the rollover issues.

Using AddDateTime()

AddDateTime() has the following syntax:

AddDateTime(DateVariable, TimeVariable, Years, Months, Days, Hours, Minutes, Seconds)

where:

  • DateVariable is a reference to the date you want to update.

  • TimeVariable is a reference to the time you want to update.

  • The other parameters are integers which will update the respective parts of the date and time. Use positive integers to add an amount, negative integers to subtract.

About Variable References

You will notice in the example that the variables for the first two parameters are entered as variable references. That is, they are written in quotes, followed by the literal VAR: 'A'VAR and 'B'VAR. This is the format Magic xpa uses refer to a variable by address. This is necessary to update the variable from within an expression. Usually Magic xpa only updates variables with an Update operation, but in this case you are updating two variables at the same time so a reference is needed.

See also

The Online and Rich Client Samples projects (program DT06 and RDT06)

Reference
Attachment 
Attachment