07-06-2012 05:57 AM
Hi,
I need small help on Formate date activity. Below are the details:
Required output format: MM'/'dd'/'yyyy hh:mm tt
Input: System date ( 05.07.2012 17:25:39)
In the above formate, tt refers to AM/PM but i am unable see AP,PM in my output.
My output: 07/05/2012 05:25
Required output: 07/05/2012 05:25 PM.
Provide
Solved! Go to Solution.
07-06-2012 07:48 AM
In the first case, you have to use a format string that matches your input to "teach" the system how to convert an arbitrary string into something known as a piece of datetime data.
The whole idea of Parse Date is to convert a string into a datetime. [Server.Current Time] is already a datetime, so this is an unecessary step, but if you wanted to try it you'd have to use the right parser string. For your datetime format,
06.07.2012 16:20 (UTC+02:00)
would be parsed properly with
dd.MM.yyyy HH:mm (UTCK)
As for the second scenario, some system cultures don't return AM/PM. Can you try checking the checkbox to "Use specified culture..." and enter "en-US"?
(I'm a little concerned about this solving it, since you're also getting dots instead of slashes so it's like the formatter isn't doing anything)
07-06-2012 07:02 AM
You can pretty much feed any style of input string, but you have to "teach" CPO how to read it.
For your case, I tried the following and got your desired output.
Use the "Parse Date" activity first:
Format String = dd.MM.yyyy HH:mm:ss
Input String = 05.07.2012 17:25:39
Then use the "Format Date" activity next:
Format String = MM/dd/yyyy hh:mm tt
Original Date = [Workflow.Parse Date.Result]
07-06-2012 07:25 AM
Hi Michael,
Thanks for reply.
I have tried your scenario as follows:
Scenairio 1)
format string : dd.MM.yyyy HH:mm:ss
Input string [Server.Current.Time]
Failing with error message "String was not recognized as a valid DateTime." input is --- 06.07.2012 16:20 (UTC+02:00)
Scenario 2:
a) Parse date activity
Format String = dd.MM.yyyy HH:mm:ss
Input String = 05.07.2012 17:25:39
Then use the "Format Date" activity next:
Format String = MM/dd/yyyy hh:mm tt
Original Date = [Workflow.Parse Date.Result]
Out put: 07.05.2012 05:25
In 2nd scenario, / is replaced with . and it is not showing the AM and PM values in output.
I am using CPO 2.3.
07-06-2012 07:48 AM
In the first case, you have to use a format string that matches your input to "teach" the system how to convert an arbitrary string into something known as a piece of datetime data.
The whole idea of Parse Date is to convert a string into a datetime. [Server.Current Time] is already a datetime, so this is an unecessary step, but if you wanted to try it you'd have to use the right parser string. For your datetime format,
06.07.2012 16:20 (UTC+02:00)
would be parsed properly with
dd.MM.yyyy HH:mm (UTCK)
As for the second scenario, some system cultures don't return AM/PM. Can you try checking the checkbox to "Use specified culture..." and enter "en-US"?
(I'm a little concerned about this solving it, since you're also getting dots instead of slashes so it's like the formatter isn't doing anything)
07-06-2012 08:09 AM
Hi Michael,
The second scenario is worked with "en-US". Without using the parsing of date i am able to get the required solution.
Thanks for providing the solution.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide