Question


Morgan Stanley
IN
Last activity: 3 May 2016 7:05 EDT
Convert string date to date time
I have a date time string the format "Apr 27, 2016 16:00" and would like to convert it to "Apr 27, 2016 16:00 PM" and then assign it to a DateTime variable.
Any suggestions on how to convert string to date time?
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution


UnitedHealth Group
IN
Hi Avinash,
The time zone is picked up from Operator or Division or Organization time zone settings from Specific to Generic.
So please check for the time zone being displayed as EDT.
Next on the why it is showing difference in time, it is simply because date time value is stored in GMT format and PEGA automatically converts to local time zone before display.
Even if this is fine, check for Database time. This may not be in sync with your application server time.
Hope this helps.
Regards,
Prasad
Updated: 27 Apr 2016 10:17 EDT


Pegasystems Inc.
GB
As a starting point: see these links in the PRPC Help:
http://prpc:port/prhelp/procomhelpmain.htm#designer studio/expressionbuilder/ref_conversions.htm
Be wary that the DateTime you want to convert to:
Apr 27, 2016 16:00 PM
Lacks any Time Zone Indicator :but PRPC DateTimes need this; the help says (my emphasis):
When presented with a DateTime value, a corresponding date and a time-of-day (in a specified time zone) can be determined.
However, the converse is not usually true: when starting with a Date and a TimeofDay value, multiple differing but "correct" DateTime values can be constructed, depending on assumptions about time zone, Daylight Savings Time, and other considerations. For example, when the date is January 1 in London, it can be December 31 in New York.
As a starting point: see these links in the PRPC Help:
http://prpc:port/prhelp/procomhelpmain.htm#designer studio/expressionbuilder/ref_conversions.htm
Be wary that the DateTime you want to convert to:
Apr 27, 2016 16:00 PM
Lacks any Time Zone Indicator :but PRPC DateTimes need this; the help says (my emphasis):
When presented with a DateTime value, a corresponding date and a time-of-day (in a specified time zone) can be determined.
However, the converse is not usually true: when starting with a Date and a TimeofDay value, multiple differing but "correct" DateTime values can be constructed, depending on assumptions about time zone, Daylight Savings Time, and other considerations. For example, when the date is January 1 in London, it can be December 31 in New York.
Likewise, when comparing two values, or computing with dates, times, and DateTime values, context is important. A time of 6:15 P.M. in London is earlier, not later, than 6:16 P.M. in New York.
If your particular Application doesn't really mean something like "The 27th of April, 2016 at 4pm as viewed on a clock in a particular timezone", but rather means something like "Just 4pm on that day": consider using a PRPC Date Property in conjunction with a PRPC TimeofDay Property; leaving the assumptions about which Timezone (if any) was meant down to the intepreration of the humans, rather than the machines having to guess (probably wrongly) what timezone was intended.


Morgan Stanley
IN
The actual use case behind converting date is in our application we are collecting date in a date variable and time in a string variable.
Now we would like to store the date & time in a single variable by combining the collected date and time data. I've used substring functions cut the string before T in date 20130806T061841.958 GMT and then tried to append time which is in 07:10 format in a string variable.
Now finally my date time variable has the data as 20130806T071000.000 GMT
Now, the issue i'm facing is when i use a datetime control to display this value its showing 4 hours before the time with EDT as the timezone. Not sure from where EDT timezone is picked. Any thoughts?
20130806T061841.958 GMT |


Pegasystems Inc.
IN
Hi Avinash,
If you are using the property the values you passed to DateTime control, through UI is shown from the local timezone where as when it stores the data as the record it stores with the time as to where the server is been set, in other words values stores with the current server time.
There has been some issues also with datetime conversion to show excat result, what is the prpc you are runnig at. Its always better to use datetime property then to perform and manuplication by using funcation, if you only want date u can use Date property for that.
Thanks


Morgan Stanley
IN
Actually the date time control is showing the timezone as EDT but i'm in IST timezone..
I'm on PRPC 7.2 version


Virtusa IT Consulting
AE
You can probably define a simple text property which allow you to do all sorts of manipulations to date.
Suppose if I have to get the date of birth in dd/mm/yyyy format I need to make use of expression builder to get the desired format of date from the given timestamp.
eg. .DateOfBirthPDF = @substring(.DateOfBirth, 4, 6) + "/" + @substring(.DateOfBirth, 6, 8) + "/" + @substring(.DateOfBirth, 0, 4)
You can use @(Pega-RULES:String).whatComesBeforeFirst(.PROPRTY,'T') expression to get the string before 'T'
Thanks,
Habeeb Baig
Accepted Solution


UnitedHealth Group
IN
Hi Avinash,
The time zone is picked up from Operator or Division or Organization time zone settings from Specific to Generic.
So please check for the time zone being displayed as EDT.
Next on the why it is showing difference in time, it is simply because date time value is stored in GMT format and PEGA automatically converts to local time zone before display.
Even if this is fine, check for Database time. This may not be in sync with your application server time.
Hope this helps.
Regards,
Prasad


Morgan Stanley
IN
Thanks Prasad.
I was under the impression that the timezone will be picked from my local machine.
My operator has the timezone as EDT.. Thanks for providing the direction.
-
toshiro miura