Expand my Community achievements bar.

SOLVED

Need to convert String value to Date Time

Avatar

Level 2

In one of my requirement, there is a last pay date field which is in String with value "YYYYMMDD". I need to convert this value to Date time option AEP. Please give some suggestion to convert.

 

Thanks,

Saravanakumar

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor and Adobe Champion

Hi @SaravanakumarB1 

do you mean the value comes in as XDM field of type string and you need to transform it into a DateTime?

For this, you could just use the date data prep functions within a calculated field.

https://experienceleague.adobe.com/en/docs/experience-platform/data-prep/functions#

 

Let's say you have the following schema

bjoern__koth_2-1767605638923.png

and a matching CSV

bjoern__koth_3-1767605660212.png

When you run a simple CSV import that creates a dummy dataset based on your schema

bjoern__koth_4-1767605702043.png

and map the fields accordingly.

 

  1. message should automatically be correct

bjoern__koth_1-1767605594325.png

2. the myDate mapping must be removed and a new calculated field (New field type > add calculated field) added instead

bjoern__koth_8-1767606248940.png

 

bjoern__koth_7-1767606132804.png

important: make sure to pass in your incoming date-string format, with "y" for year, "M" for month and "d" for day.

date(myDate, "yyyyMMdd")

 

After importing the csv, your dataset should look something like this

bjoern__koth_5-1767605791266.png

 

Cheers from Switzerland!


View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor and Adobe Champion

Hi @SaravanakumarB1 

do you mean the value comes in as XDM field of type string and you need to transform it into a DateTime?

For this, you could just use the date data prep functions within a calculated field.

https://experienceleague.adobe.com/en/docs/experience-platform/data-prep/functions#

 

Let's say you have the following schema

bjoern__koth_2-1767605638923.png

and a matching CSV

bjoern__koth_3-1767605660212.png

When you run a simple CSV import that creates a dummy dataset based on your schema

bjoern__koth_4-1767605702043.png

and map the fields accordingly.

 

  1. message should automatically be correct

bjoern__koth_1-1767605594325.png

2. the myDate mapping must be removed and a new calculated field (New field type > add calculated field) added instead

bjoern__koth_8-1767606248940.png

 

bjoern__koth_7-1767606132804.png

important: make sure to pass in your incoming date-string format, with "y" for year, "M" for month and "d" for day.

date(myDate, "yyyyMMdd")

 

After importing the csv, your dataset should look something like this

bjoern__koth_5-1767605791266.png

 

Cheers from Switzerland!


Avatar

Level 2

We are fetching data from S3, in the file the pay_date value they have given as "20351209". I need to convert this value to UTC timestamp. Please advice

Avatar

Community Advisor and Adobe Champion

The mapping should still be done in your S3 import workflow. And the result will be transformed into an UTC timestamp with midnight as hour:minutes part.

bjoern__koth_1-1767606532163.png > bjoern__koth_2-1767606548095.png

bjoern__koth_0-1767606479867.png

Cheers from Switzerland!