It's possible
to have a requirement to compare dates coming from different sources such as
Field Values, Methods (Timestamp or Today), or Integrations. They may be in
different formats making comparisons sometimes difficult.
Being able to format a date string to be similar to another format is useful and doing so without Script is very desirable. This post shows a Workflow technique using the ToChar Method to format date strings without Script where both the input date and the format are dynamic process properties.
Being able to format a date string to be similar to another format is useful and doing so without Script is very desirable. This post shows a Workflow technique using the ToChar Method to format date strings without Script where both the input date and the format are dynamic process properties.
Solution
Create
a Workflow process with three process properties:
1. BeforeDate
a. Type: Date
b. Default Date (for testing only) 08/11/2011 06:06:54
2. AfterDate
a. Type: String
3. DateFormat
a. Type:String
b. Default String: "M/DD/YY"
1. BeforeDate
a. Type: Date
b. Default Date (for testing only) 08/11/2011 06:06:54
2. AfterDate
a. Type: String
3. DateFormat
a. Type:String
b. Default String: "M/DD/YY"
NOTE:
The Process Property that holds the input date must be of type Date. If one
tries to use String as the Data Type for the Process Property holding the input
date the format will be ignored in the ToChar Method and the date will simply
be copied as a string to the Output Process Property.
Add three steps to the Workflow.
1. Start
2. Business Service
a. Business Service Name: Workflow Utilities
b. Business Service Method: Echo
3. Add an Output Argument to the Business Service step with the following properties.
a. Property Name: AfterDate
b. Type: Expression
c. Value: ToChar([&BeforeDate], [&DateFormat])
4. Connect them so that the final Workflow Process looks like this figure 1.
Figure 1 This is the way the test workflow looks.
5. The ToChar Method will take our input date and our desired format and produce a string in the format desired. When simulating the Workflow one can see the input and output in figure 2.
Figure 2 This
is the resulting formatted date string
M = Month as a single digit
MM = month as two digits
m = minutes as single digit
mm = minutes as two digits
DD = two digit days
YYYY = four digit years
HH = hours
MM = minutes (if after the hours token)
SS = seconds
IS this really working.. I tried the same and getting SBL-BPR-00121 error
ReplyDeleteHi
Deleteits working.Send ur email Id i will send u the Workflow xml
HI,
DeletePlease send me upendarkerp@gmail.com
Its working fine but i want to use system date and today() function is not working in default string value. please suggest me i want to perform this task
ReplyDeleteToChar([&BeforeDate] + 1, [&DateFormat]) + ' ' + '09:00 AM'
Use another echo function to get the Today() value for this Date Variable
DeleteThats - That work nice in 7.5 workflow, getting the month date from today (ie. 1-31)
ReplyDelete: ToChar(Today(), "D")
Yay!
Hi.. is it possible to have a string format and convert to date in workflow without scripting?
ReplyDeleteThe proper syntax for Hours, Minutes and Seconds should be specified in LOWERCASE (hhmmss) instead of uppercase (HHMMSS).
ReplyDelete'To_Char(TimeStamp(), 'DDMMYYYY_hhmmss')'
Reference: Doc ID 1360284.1
I have been browsing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my opinion, if all web owners and bloggers made good content as you did, the web will be a lot more useful than ever before. Process audits
ReplyDeletewhat if I want Month as JAN or FEB?
ReplyDeleteHow to pass date field to ToChar function?.I tried this ToChar([EAI Sync Date], "MM-DD-YY") but output is not in the format MM-DD-YY instead it is 03/20/2024 07:00:00
ReplyDelete