How Do I Retrieve the Current Date? (Magic xpi 4.5)
Getting the current date in Magic xpi is done using the Date() function. Date() returns the system date, as it exists on the machine Magic xpi is running on.
Dates in Magic xpi are stored internally as an integer, which represents the number of days since the year zero. This isn’t something you need to deal with, since all the conversions are done automatically. But it means that in terms of arithmetic, a date is considered just a number. So if you add 5 to a date, you get a date 5 days from the original. You don’t need to worry about issues like “is the date at the end of the month” or “is it a leap year”.
Using the Date() function:
The Date() function is often used in the Data Mapper This will enter the current date for the delivery date, and is also useful for setting timestamps for when a record was created or modified.
To use it, you just type Date(). At runtime, the function will be replaced by the current date.
If you want to change the format of the date, such as American (MM/DD/YY) or European (DD/MM/YY), you can use the DStr() function. For more information about this, see Using the DStr() function in the
How Do I Convert a Date Value to a String? topic.
If you want to add a numeric expression to this function, such as Date()+10, use the AddDate() function instead. This is because Magic xpi does not allow numeric expressions in Date fields.