iNTERFACEWARE Products Manual > Installing and Using Chameleon > Using Python Scripting > Chameleon Python API > Environment Variable > Converting a Date from Double to String |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
In Python, dates are represented as strings in segment-level Python scripts, but are represented in a date time double precision format in table-level Python scripts and the Table Object. To convert a date from a double to a string, use the double_to_date_time() and format_date_time() functions. The double_to_date_time() function is the simplest way to convert a date in double precision format to a string:
Here, DoubleDate is the date to be converted, and Format is the format of the date. This format is one of the date time formats listed in the Date Time Formats section of the Chameleon Workspace:
The format_date_time() function converts a date in double precision format into a formatted string:
Here, DoubleDate is the string to be converted, and FormatString is the format string to use when converting. This format string uses conversion specifiers to specify the format. The following table lists some of the valid conversion specifiers that can be used in the string specified by FormatString:
You can use these functions when generating HL7 messages. Use a Table Outbound script to extract a date from a table, and then use a Segment Outbound script to load this date into a field of the message you are generating. The Table Outbound script just assigns the date to a global variable:
The Segment Outbound script then converts the date to the format used in message segments. In this script, you can use double_to_date_time() to generate a date in a standard format:
Or you can use format_date_time() to generate a date in a custom format:
|