Convert Text to Date Time

Converts dates contained in texts to date time values.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Converts dates contained in texts to date time values, formatted as "YYYY-MM-dd HH:mm:ss".

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.

textToDateTime [--culture(String)] --text(String) [--usecustomformat(Boolean)] --customformat(String) (DateTime)=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
Text to convert text Required Text Text containing the value that should be converted to "Date Time". Visit the Standard Date Time Format Strings External link documentation to learn more.
Use custom date format usecustomformat Optional Boolean Enable to use a custom date format to identify the date in the text.
Custom format customformat Required when the Use custom date format parameter is enabled Text Custom date format to identify the date in the text.

See the customformat limitations.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Date Time value Date Time Date Time value obtained from the text after conversion.

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

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.

Example

Example 1: Converts a text using a custom format and returns the Date Time value found.

defVar --name textDateTime --type String --value "14/08/2014"
defVar --name dateTimeConverted --type DateTime
defVar --name customFormat --type String --value "dd/MM/yyyy"
textToDateTime --text "${textDateTime}" --usecustomformat--customformat "${customFormat}" --culture en-US dateTimeConverted=value
logMessage --message "${dateTimeConverted}" --type "Info"
//Returns (2014-08-14 00:00:00).

Example 2: Converts a text without using a custom format and returns the Date Time value found.

defVar --name textDateTime --type String --value "07/15/2024"
defVar --name dateTimeConverted --type DateTime
textToDateTime --text "${textDateTime}" --culture en-US dateTimeConverted=value
logMessage --message "${dateTimeConverted}" --type "Info"
// Returns (2024-07-15 00:00:00).