The following article provides an example of performing calculations on date objects and how to set corresponding document properties values with the result of the calculation. Two (2) document properties of type 'Date' are used and are attached to input field property controls in a Text Area. This example supports different locale sets on the client operating system.
Introduction
The following article provides an example of performing calculations on date objects and how to set corresponding document properties values with the result of the calculation. Two (2) document properties of type 'Date' are used and are attached to input field property controls in a Text Area. This example supports different locale sets on the client operating system.
Code Sample
# Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license. from Spotfire.Dxp.Data import DataType, DataValue from System import DateTime # Retrieve the current date, and store it in a variable. today = DateTime.Today # Perform some calculation by subtracting one(1) year from the current date. lastyear = today.AddYears(-1) # Convert DateTime objects to Spotfire types. sToday = DataValue.Create(DataType.Date,today.Date) sLastYear = DataValue.Create(DataType.Date, lastyear.Date) # Set document properties with dates value, and not the wrapper object. Document.Properties["pStartDate"] = sLastYear.ValidValue Document.Properties["pEndDate"] = sToday.ValidValue
References
License: TIBCO BSD-Style License
Recommended Comments
There are no comments to display.