Question


Infosys
IN
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
Updated: 4 Jul 2022 10:12 EDT


Pegasystems Inc.
BR
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"+@String.replaceAll(@String.whatComesAfterFirst("2022-06-26T10:00:00.000",'T'),":","")
Based on you input sample this code will return Pega DateTime format.


Infosys
IN
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.


IQZ Systems
US
@SAMSONB4 If you have the datetime in GMT & want to convert to CET, you can use FormatDateTime OOTB function
Updated: 4 Jul 2022 11:21 EDT


Capgemini
IN
@SAMSONB4 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
IN
Hi Bharath,
Thanks for your response.
@ConvertDateTime is this a default function defined in pega ?


Capgemini
IN
@SAMSONB4 yes


Infosys
IN
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
IN
Hi @SAMSONB4 ,
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
IN