How to edit TIMESPAN and DATE variables in NA
The TIMESPAN and DATE type variables are not compatible with the DataEdit object which means there is no easy way to let the user enter a new value for these data types.
Sysmac does have keyboards which allow you to enter TIMESPAN or DATE types. These keyboards can be called manually via script.
Example: Modifying a TIMESPAN via script
1. Define your TIME variable on the PLC

2. Define your TIMESPAN variable mapping on the HMI

3. Create a “DataDisplay” object linked to your TIMESPAN variable

4. Create an action which triggers when the user clicks the DataDisplay. The action will call a subroutine.

5. Add the following code to your subroutine (adjust the variable name as required)
Sub GetTIMEKeypad
EditVariable( "HMITimeSpan")
End Sub
Your DataDisplay should now automatically show a keypad when pressed that allows you to edit the TIMESPAN variable.

Example: Modifying a DATE via script
DATE keypads can be generated in much the same way as Timespan keypads. We have created a separate section for the DATE type as the default keypad should be modified as the default range is from the year 2000 to 2025.
1. Define your DATE_AND_TIME variable on the PLC

2. Define your DATE variable mapping on the HMI

3. Create a “DataDisplay” object linked to your DATE variable

4. Create an action which triggers when the user clicks the DataDisplay. The action will call a subroutine.

5. Add the following code to your subroutine (adjust the variable name as required)
Sub GetDATEKeypad
EditVariable( "HMIDate",,,,,,,,,"Group0")
End Sub
6. Create a custom keypad group and add a DateTimeKeypad

7. Edit the DateTimeKeypad. Select the "Year" drop-down and go to assign. You can modify the range by clicking the "+" icon. Modify the items as required to get the desired range of years. Note that a value of 0 correlates to the year 2000.

Your DataDisplay should now automatically show a keypad when pressed that allows you to edit the DATE.
