Length of service variable

 1 Replies
 0 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
Shane Jones
Veteran Member
Posts: 460
Veteran Member
    I am trying to do something that I thought would be simple.

    I have a flow that is pulling the associates hire date and effective date.... I want to calculate the length of service in days and I am not able to get this to work...

    I have tried a bunch of different formulas and none of them seem to be working. I can not even do a simple )date1-date2) I found formulas like:

    datediff(var1,var2)
    (date1-date2)*millisecondsToDays
    ((ddate-bdate)/365.25)
    dayElapsed(date1, date2)

    I have set it up as an integer, double, date.... I can't figure out what I am missing? Anyone have a flow that calculates in days or years that I could use. I am just looking to create a branch based on length of service so it does not matter it is displays in days, months, years (1.25), or minutes... I can build the branch off of any of these.

    Thanks
    Shane

    Shane Jones
    Tools: HR, Payroll, Benefits, PFI, Smart Office, BSI, Portal and Self-Service
    Systems: Lawson, Open Hire, Kronos, Crystal Reporting, SumTotal Learning
    ** Teach others to fish...
    John Henley
    Posts: 3353
      Hi Shane,

      I find Javascript date logic (particularly in relation to Lawson's date formats) to be particularly tricky.

      Here's how I do it (in Design Studio; you'll have to adjust it for ProcessFlow):

      - Put both dates into a date() variable (to do that *correctly* particularly for sites with different locales, see my LawsonGuru article https://www.danalytics.co...archive/2006-09.htm)

      - Use a combination of milliseconds, .getTime() and Math.ceil() to get the difference in days.

      Here's the relevant code (I've also attached it in a .txt file in case it doesn't render correctly...)

      var dateToday = new Date();
      var sPostDate = lawForm.getDataValue("CGH-BATCH-DATE")
      if (sPostDate == "")
      {
      sPostDate = portalWnd.edFormatDate("t")
      }
      var dPostDate = new Date(sPostDate)

      //Set 1 day in milliseconds
      var one_day = (1000*60*60*24)

      // calculate age of posting date & warn if > 90 days ago
      var iPostDaysOld = Math.ceil( (dateToday.getTime() - dPostDate.getTime()) / one_day)
      if (iPostDaysOld > 90)
      {
      }
      Attachments
      Thanks for using the LawsonGuru.com forums!
      John