top of page

Moji5 Knowledgebase

Usage of New DateTime in the Behavior

In this post, will be showing the enhancement for the new DateTime in the behavior.

To assign a value to the DateTime field, need to put:

Data("MyDateField")=Now.tostring("yyyy-MM-dd")
Data("MyDateTimeField")=Now.tostring("yyyy-MM-ddTHH:mm")

Now.tostring will convert the datetime format into string to assign to the field.

Example of usage:

In this situation, the "NewDate" field will be assigned with today's date when the field YesNo is chosen as 'Yes'

Example how it looks in the form:

When user change the "Yes No" field to 'Yes', the "NewDate" field will update to today's date.

When user change to 'No', the "NewDate" will reset to blank.


This is a rather basic way of assigning the values into the datetime field, the new datetime field is pretty easy to assign different dates like adding days or subtracting days from the current day or from another date.


Function DateAdd works as returns a Variant (Date) containing a date to which a specified time interval has been added.

DateAdd("m", 1, date)

In the code snippet above, "m" is the interval type being "m" = month, "d" = days, "y" = Day of Year, 1 is the number to add(positive) or subtract(negative) the date, and "date" is the date to which the interval is added.

Example for adding days to the date:

Example for subtracting the days:

'-' is there to subtract the days.

How the form reflects the code:

These examples are of the few ways to interact with the datetime field in M5.

Comments


bottom of page