Question


Infosys
BE
Last activity: 5 Jul 2022 15:23 EDT
How to set a string vale to Date/Time property
HI,
In a Data Transfrom, I need to set 2022-06-26T10:00:00.000 this value to a Date/Time property. But, getting an exception "2022-06-27T12:00:00.000 is not a valid date/time value". The property data type can't be changed to Text. Still new to achieve this.
Can anyone give some suggestion ?
Thanks
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Updated: 4 Jul 2022 10:12 EDT


Pegasystems Inc.
US
Hi @SAMSONB4,
I was not able to find a single function which could convert your string format to Datetime, however if you have always the same input pattern you can try below:
@String.replaceAll(@String.whatComesBeforeFirst("2022-06-26T10:00:00.000",'T'),"-","")+"T"[email protected](@String.whatComesAfterFirst("2022-06-26T10:00:00.000",'T'),":","")
Based on you input sample this code will return Pega DateTime format.


Infosys
BE
I've used this approach it is working. But again the value is getting converted to GMT. As it is a Date/Time Property Pega is taking GMT format again. Even though the conversion to CET is performed.
Updated: 4 Jul 2022 11:21 EDT


Capgemini
IN
@SAMSON B you can use below parameters and convertdatetime function to change into datetime format as per your requirement
define below parameters in DT:
Param.pegaDateFormat value as "yyyyMMdd'T'HHmmss.SSS 'GMT'" Param.pegaTZ value as "GMT"
Param.srcDateFormat value as "yyyy-MM-dd'T'HH:mm:ss"
Param.srcTZ value as "Europe/Brussels" (you can use different timezone as well based upon your requirement)
and set the property to @ConvertDateTime(@substring(.propertyname,0,19),Param.srcDateFormat,Param.srcTZ,Param.pegaDateFormat,Param.pegaTZ))
Thanks,
Bharath s


Infosys
BE
Hi Bharath,
Thanks for your response.
@ConvertDateTime is this a default function defined in pega ?


Infosys
BE
when I try to give @ConvertDateTime - getting this error, seems this is not pre-defined. Source— Invalid expression or reference: No candidates found [possible function name, ruleset/version or number of parameter problem]
Updated: 4 Jul 2022 14:08 EDT


Cognizant Technologies
IN
Hi @SAMSON B ,
If your requirement is to show DateTime on UI, set string value as Pega GMT format by removing spaces,-,: in DT and update your Date Control display format.
Example Pega GMT format 20220704T175713.046 GMT


Infosys
BE