Skip to main content


 

Symptoms


How to convert a DateTime data type to different types.
 

Diagnoses


Possible with Inline Functions.
 

Resolution

You can use the functions ToDate(), ToTime(), and ToDateandTime() from 'Operators -> Inline Functions -> Conversion'. Please see the following documentation:

Inline Functions - Conversion: http://help.k2.com/onlinehelp/K2blackpearl/UserGuide/current/webframe.html_Conversion.html
Using Inline Functions: http://help.k2.com/onlinehelp/k2smartforms/UserGuide/current/default.htm_Build/Workflows/ContextBrowser_Using_Inline_Functions.htm

Please note that if done in SmartForms, the conversions take into account the difference in time zone between the server and end user. A common issue that occurs is when a server time zone DateTime is set to 12am (or 00:00:000) and gets converted to Date only, the result is shown as the day before the DateTime's day. A workaround for this is as follows:

Add an Expression that takes in the original DateTime and truncates the time component. This can be added directly to a calendar control, and looks like the following:

Left( datetime, 10 )

This will return 10 characters from the left side, assuming the standard SmartForm-converted DateTime format of 'YYYY-MM-DD HH:MM:SSZ', which will not be converted by the Calendar control.




 
Be the first to reply!

Reply