Table of Contents | ||||
---|---|---|---|---|
|
...
How does it work in the search window?
Select Create column in the search window toolbar, then select the Parse date operation. You need to specify at least two arguments:
Argument | Data type | More information | ||
---|---|---|---|---|
String to be parsed mandatory | string | |||
Date format mandatory | string | Enter the format of the string in the first argument exactly as it appears. You must use the notation for valid format patterns described below.
| ||
Time zone | string | You need a valid string format the app can recognize so it returns meaningful results. If you leave the field empty or introduce a value the app cannot recognize, the default Time Zone is UTC. You can use one of the following methods:
| ||
Locale | string | Applies the correct language to the date based on the locale you specify. If this argument is not added, the date will be in your own locale, which is determined by your user preferences. The accepted formats for the locale argument correspond to the ISO 639-1 codes, which consist of two-character codes ("en" for English, "es" for Spanish, "fr" for Frech or "de" for German), or a combination of this with the ISO 3166-2, which consists of two-character codes for specific countries ("gb" for United Kingdom, "es" for Spain...) and together they result in a four-character code specifying the subdivision ("en-us" for American English, etc.). It must not be confused with the ISO codes that consist of three-character codes.
|
The data type of the values in the new column is timestamp.
In the Date format argument, enter the exact format of the strings to be converted using the following patterns.
Type | Valid format patterns | Example |
---|---|---|
Year | YY, YYYY | 19, 2019 |
Month | M, MM, MMM, MMMM | 7, 07, Jul, July |
Day in month | D, DD | 9, 09 |
Hour (0...23, 00...23) | H, HH | 7, 07 |
Hour (1...12, 01...12) | h, hh | 7, 07 |
AM/PM | A | |
Minute | m, mm | 3, 03 |
Second | s, ss | 8, 08 |
Millisecond (000...999) | SSS | 056 |
Weekyear (15, 2015) | GG, GGGG | |
Week of week year (1...53, 01...53) | W, WW | 5, 05 |
Parse TimeZone offset (-0700, ...+0700) | ZZ |
If the string to be parsed contains literal text, enclose it inside square brackets [] so it can be correctly isolated and omitted when transformed. In the following example you can see how the literal text and date format must be treated:
String to be parsed → Event occurred on January 23 of 2020 at 10:38
Date format → [Event occurred on] MMMM DD [of] YYYY [at] HH:mm
Example 1
Let's transform the Timestamp field in the demo.ecommerce.data
table into timestamp format.
Click Create column and select the Parse date operation. Assign a name to the new column - let's call it simply parsedate. Now, add the following arguments:
...
Let's say we want to transform the Str_Timestamp field, which has the months in Spanish, into Timestamp format.
Click Create column and select the Parse date operation. Assign a name to the new column - let's call it simply parsedate. Now, add the following arguments and click Create column:
...
Use the operator select
... as
... and add the operation syntax to create the new column. These are the valid formats of the operation:
parsedate(string_to_be_parsed, format_string)
parsedate(string_to_be_parsed, format_string, time_zone_string)
parsedate(string_to_be_parsed, format_string, time_zone_string, locale_string)
...
Copy the following LINQ script and use it to replicate the first example on the demo.ecommerce.data
table.
Code Block |
---|
from demo.ecommerce.data select parsedate(timestamp, "DD/MMM/YYYY:HH:mm:ss +SSSS") as parsedate |
...