Convert Date Time to Text
Converts a value type from Date Time
to Text
.
Command availability: IBM RPA SaaS and IBM RPA on premises
Script syntax
IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.
dateTimeToText [--culture(String)] --date(DateTime) [--usecustomformat(Boolean)] --customformat(String) --standardformat(StandardDateTimeFormat) (String)=value
Input parameters
The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.
Designer mode label | Script mode name | Required | Accepted variable types | Description |
---|---|---|---|---|
Language | culture |
Optional |
Text , Culture |
Language options for conversion. See the culture parameter options. |
Date | date |
Required |
Date Time |
Date Time to be converted to Text . |
Use custom format | usecustomformat |
Optional |
Boolean |
Enabled to use a custom format for the date and time to be converted. |
Format | customformat |
Required when the Use custom format parameter is enabled |
Text |
Custom Date and Time format for the conversion. See the customformat limitations. |
Format | standardformat |
Required when the Use custom format parameter is disabled |
StandardDateTimeFormat |
Set of standard date formats. See the standardformat parameter options. |
Output parameters
Designer mode label | Script mode name | Accepted variable types | Description |
---|---|---|---|
Text | value | Text |
Returns the "Date Time" converted to Text . |
culture
parameter options
The following table displays the options available for the culture
input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.
Designer mode label | Script mode name |
---|---|
Chinese (zh-CN, zh-TW, zh-Hans, zh-Hant) | zh-CN, zh-TW, zh-Hans, zh-Hant |
English (en-US) | en-US |
French (fr-FA, fr-CA) | fr-FA, fr-CA |
German (de-DE) | de-DE |
Italian (it-IT) | it-IT |
Japanese (ja-JP) | ja-JP |
Korean (ko-KR) | ko-KR |
Portuguese (pt-PT, pt-BR) | pt-PT , pt-BR |
Russian (ru-RU) | ru-RU |
Spanish (es-ES) | es-ES |
standardformat
parameter options
The following table displays the options available for the standardformat
input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.
Designer mode label | Script mode name | Description |
---|---|---|
Short date | ShortDate |
Option to display short date format: DD/MM/YYYY. |
Long date | LongDate |
Option to display long date format: Weekday DD, Extended Month, YYYY. |
Short time | ShortTime |
Option to display short time format: HH:mm. |
Long time | LongTime |
Option to display long time format: HH:mm:SS. |
Long date and long time | FullDateTime |
Option to display long date and long time format: Weekday DD, Extended Month, YYYY, HH:mm:SS. |
Month and day | MonthDay |
Option to display month and day time format: DD, Extended Month. |
Time value, which is based on the Internet Engineering Task Force (IETF) Request for Comments (RFC) | RFC1123 |
Option to display RFC1123 date format: Abbreviated Weekday DD, Abbreviated Month, YYYY HH:mm:SS GMT. |
Year and month | YearMonth |
Option to display year and month date format: Full Month YYYY. |
Sortable date and time | SortableDateTime |
Option to display sortable date time: YYYY-MM-DDTHH:mm:SS. |
Universal sortable date and time | UniversalSortableDateTime |
Option to display universal sortable date time: YYYY-MM-DD HH:mm:SSZ. |
Example
Example 1: Converts a date to text in the Short date format and returns it.
defVar --name dateAndTime --type DateTime --value "2019-08-15 12:18:18"
defVar --name dateTimeText --type String
dateTimeToText --date "${dateAndTime}" --standardformat "ShortDate" --culture en-US dateTimeText=value
logMessage --message "${dateTimeText}" --type "Info"
// Conversion of the date (2019-08-15 12:18:18) to ShortDate format.
// Date converted (08/15/2019).
Example 2: Converts a date to text in the Long date and long time format and returns it.
defVar --name dateAndTime --type DateTime --value "2019-08-05 12:18:18"
defVar --name dateTimeText --type String
dateTimeToText --date "${dateAndTime}" --standardformat "FullDateTime" --culture en-US dateTimeText=value
logMessage --message "${dateTimeText}" --type "Info"
// Conversion of date (2019-08-05 12:18:18) to FullDateTime format.
// Date converted (Monday, August 5, 2019 12:18:18).
Example 3: Converts a date to text in custom format and returns it.
defVar --name dateAndTime --type DateTime --value "2019-08-05 12:18:18"
defVar --name dateTimeText --type String
defVar --name CustomFormat --type String --value "MM/dd/yyyy"
dateTimeToText --date "${dateAndTime}" --usecustomformat--customformat "${CustomFormat}" --culture en-US dateTimeText=value
logMessage --message "${dateTimeText}" --type "Info"
// Date conversion (2019-08-05 12:18:18) to custom format.
// Date converted (08/05/2019).
Limitations
- If you want to use a custom mask and a format specifier that is related to a culture, you need to supply both mask and culture.
- If you want to use a custom mask that is not related to a culture, leave the
culture
parameter blank.