PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 7/17/2015 1:45 PM by  Wanda Schaaf
How to use the DateDiff variable in Process Flow?
 20 Replies
Sort:
You are not authorized to post a reply.
Author Messages
ryand
Veteran Member
(117 points)
Veteran Member
Posts:51


Send Message:

--
10/27/2009 7:45 PM

    Can you use the DateDiff function to compare two dates in YYYYMMDD or MM/DD/YYYY format?  When I compare the dates in JS format it gives me an error "TypeError: Cannot find function getTime.

    John Henley
    Private
    Private
    Senior Member
    (9887 points)
    Senior Member
    Posts:3313


    Send Message:

    --
    10/28/2009 4:20 PM
    You need to pass in a date variable not a string (you can convert to date format using pfDate() function, e.g.:
    DateDiff(pfDate(datestring1,'yyyy/mm/dd'),pfDate(datestring2,'yyyy/mm/dd'))
    Thanks for using the LawsonGuru.com forums!
    John
    ryand
    Veteran Member
    (117 points)
    Veteran Member
    Posts:51


    Send Message:

    --
    10/28/2009 6:40 PM

    I'm getting a result like this: 1.0810584E12? 

    John Henley
    Private
    Private
    Senior Member
    (9887 points)
    Senior Member
    Posts:3313


    Send Message:

    --
    10/28/2009 7:17 PM
    Well, what dates are you using?
    ________________________________
    From: forums-bpm-pflow@lawsonguru.com [forums-bpm-pflow@lawsonguru.com]
    Sent: Wednesday, October 28, 2009 4:04 PM
    To: John Henley
    Subject: RE: How to use the DateDiff variable in Process Flow? [00006700:00009155]

    [https://images.lawsonguru.com/logos/LawsonGuru_com_200.jpg]<https://www.lawsonguru.com/>
    Lawson ProcessFlow Forum Notification
    A message was posted to a thread you are tracking.
    RE: How to use the DateDiff variable in Process Flow?
    Posted by: ryand
    10/28/2009 03:40 PM

    I'm getting a result like this: 1.0810584E12?


    ________________________________

    To view the complete thread and reply via your browser, please visit:
    https://www.lawsonguru.co...fc/9155/Default.aspx

    You were sent this email because you opted to receive email notifications when someone posted and/or responded to a message on this forum.
    To unsubscribe to this thread please visit your user profile page and change your subscription options.

    Thank you,
    LawsonGuru.com

    Thanks for using the LawsonGuru.com forums!
    John
    Sam Simpson
    Private
    Private
    Veteran Member
    (673 points)
    Veteran Member
    Posts:239


    Send Message:

    --
    10/28/2009 7:42 PM
    John's example should work except put two (( in front. i.,e. DateDiff((.....
    ryand
    Veteran Member
    (117 points)
    Veteran Member
    Posts:51


    Send Message:

    --
    10/28/2009 8:25 PM

    Nice, i finally got it to work using John's example.  Thanks for your help as always!

    Karen Sheridan
    Private
    Private
    Veteran Member
    (367 points)
    Veteran Member
    Posts:141


    Send Message:

    --
    3/30/2011 3:33 PM
    I am trying to use DateDiff with 2 fields that should already be dates:

    DateDiff(PERSACTION_EFFECT_DATE, Today())

    I've tried various combinations, but haven't found one that works other than just hard coding the dates and using pfDate.

    TIA,
    Karen
    David Williams
    Private
    Private
    Veteran Member
    (3343 points)
    Veteran Member
    Posts:1125


    Send Message:

    --
    3/30/2011 3:47 PM
    When you reference a variable from a Query or an AGS call the variable is usually in a String format. You would have to reassign it to a date variable in order for the DateDiff function to work.
    David Williams
    Karen Sheridan
    Private
    Private
    Veteran Member
    (367 points)
    Veteran Member
    Posts:141


    Send Message:

    --
    3/30/2011 4:08 PM
    Do you know if Today() needs conversion? It gives me an error if I try to pfDate convert it.

    Here is my code that isn't working:
    DateDiff(pfDate(PERSACTION_EFFECT_DATE,'YYYYMMDD'),today()) > 3
    David Williams
    Private
    Private
    Veteran Member
    (3343 points)
    Veteran Member
    Posts:1125


    Send Message:

    --
    3/30/2011 4:18 PM
    You would be better off creating two variables with the dates you want to compare and then use those variables in your DateDiff function.
    David Williams
    Karen Sheridan
    Private
    Private
    Veteran Member
    (367 points)
    Veteran Member
    Posts:141


    Send Message:

    --
    3/30/2011 6:37 PM
    This now working, but....
    I added a variable strRunDate = DateString(today(),'yyyymmdd')

    Then the condition code is
    DateDiff(pfDate(PERSACTION_EFFECT_DATE,'mm/dd/yyyy'),pfDate(strRunDate,'yyyymmdd')) > 3

    the 2 dates are 10 days apart - its evaluating correctly and sending the email, but I am getting this error

    Flow ended with error code (1) - Activity error
    Information code: 0
    Return message: All Branch Conditions false
    Error occurred in activity: Branch6250
    David Williams
    Private
    Private
    Veteran Member
    (3343 points)
    Veteran Member
    Posts:1125


    Send Message:

    --
    3/30/2011 6:52 PM
    Well, that's a Branch error and if you're saying the email is working, it must be a Branch later in the flow?
    David Williams
    Karen Sheridan
    Private
    Private
    Veteran Member
    (367 points)
    Veteran Member
    Posts:141


    Send Message:

    --
    3/30/2011 7:04 PM
    Branch6250 is the branch that triggers the email or ends the flow.
    David Williams
    Private
    Private
    Veteran Member
    (3343 points)
    Veteran Member
    Posts:1125


    Send Message:

    --
    3/30/2011 7:16 PM
    That error in a Branch usually means that none of the conditions you set up were met and so it throws an error. Are you sure your DateDiff statement is working? Have you tried it where the email shouldn't be sent?

    So you have two branch conditions in your Branch node? The first would be your DateDiff statement and the 2nd should be just the word true. The last condition in any Branch node should always be true so that the system knows that if none of the preceding conditions were met then the last one should always be followed.
    David Williams
    Wanda Schaaf
    Private
    Private
    Basic Member
    (28 points)
    Basic Member
    Posts:12


    Send Message:

    --
    7/16/2015 6:08 PM
    Hello, I am struggling to get the DATEDIFF function to work in a branch situation. I am just trying to get a basic hardcoded statement to evaluate successfully.
    This is the message I am getting in the Console screen when I run it remotely from Infor Process Designer.

    Is there something I am doing wrong in the statement below?
    Activity Branch650: Error evaluating expression: DATEDIFF(DAY,pfDate('20150701','yyyymmdd'),pfDate('2015/05/01','YYYY/MM/DD')) > 1

    Thanks for any feedback!
    Wanda
    David Williams
    Private
    Private
    Veteran Member
    (3343 points)
    Veteran Member
    Posts:1125


    Send Message:

    --
    7/16/2015 6:26 PM
    The Branch isn't really a good place to build complicated conditions. I would recommend you create a boolen variable (true or false) and use a JavaScript expression (Assign) to do your function and then update the boolen variable with the results (true or false) and use that variable in the Branch.
    David Williams
    Wanda Schaaf
    Private
    Private
    Basic Member
    (28 points)
    Basic Member
    Posts:12


    Send Message:

    --
    7/16/2015 6:30 PM
    Thanks, I will give that a shot.
    Wanda
    Woozy
    Private
    Private
    Veteran Member
    (3493 points)
    Veteran Member
    Posts:709


    Send Message:

    --
    7/16/2015 6:42 PM
    Hi Wanda - The issue is that you have "DAY" as a parameter, but the Pflow DATEDIFF function only takes two dates as parameters, and then returns the number of days between those dates (absolute value).

    So, try this instead: DATEDIFF(pfDate('20150701','yyyymmdd'),pfDate('2015/05/01','YYYY/MM/DD')) > 1

    David is correct that it is better to do the boolean check outside of the branch, it should work within it as well in this case. I often do this to avoid creating bunches of variables that are really "throw aways".
    Kelly Meade
    J. R. Simplot Company
    Boise, ID
    Wanda Schaaf
    Private
    Private
    Basic Member
    (28 points)
    Basic Member
    Posts:12


    Send Message:

    --
    7/16/2015 7:05 PM
    I tried Woozy's and David's suggestions and am still getting errors:

    Activity Assign6030: Error evaluating expression: BoolDayDiff = DATEDIFF(DAY,pfDate('20150701','yyyymmdd'),pfDate('2015/05/01','YYYY/MM/DD')) > 1;
    Variables in Process:
    BoolDayDiff = null

    Activity Assign6030: Error evaluating expression: BoolDayDiff = DATEDIFF(pfDate('20150701','yyyymmdd'),pfDate('2015/05/01','YYYY/MM/DD')) > 1;
    Variables in Process:
    BoolDayDiff = null

    Branch Branch650: Executing this branch node...
    Activity Branch650: Error evaluating expression: DATEDIFF(pfDate('20150701','yyyymmdd'),pfDate('2015/05/01','YYYY/MM/DD')) > 1
    Branch Branch650: evaluating branch rule DATEDIFF(pfDate('20150701','yyyymmdd'),pfDate('2015/05/01','YYYY/MM/DD')) > 1 to node AssisnStart
    Branch Branch650: evaluating branch rule 1 ==1 to node End-SQLEmpD

    Thanks for any extra help.
    Woozy
    Private
    Private
    Veteran Member
    (3493 points)
    Veteran Member
    Posts:709


    Send Message:

    --
    7/16/2015 8:23 PM
    Hi Wanda,

    Two things - js is case sensitive, so it needs to be "DateDiff" rather than "DATEDIFF". Also, your second date parameter format won't work. The only two format options are "yyyymmdd" and "mm/dd/yyyy" (also lower case).

    This is what worked for me: DateDiff(pfDate('20150701','yyyymmdd'),pfDate('20150501','yyyymmdd')) > 1
    Kelly Meade
    J. R. Simplot Company
    Boise, ID
    Wanda Schaaf
    Private
    Private
    Basic Member
    (28 points)
    Basic Member
    Posts:12


    Send Message:

    --
    7/17/2015 1:45 PM
    Your statement above worked for me also. Thanks for all the great tips. I applied my variables to the statement also in the assign node and I have that working also.
    This is a great site and I am very greatful for the quick responses and help from everyone.

    Thanks again.
    Wanda Schaaf
    You are not authorized to post a reply.