count no of days

hi,

for ex, if i enter some date from that date till today how many days? how to count no of days 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I find it helpful to create an Expression Rule in my environments that can do a null-safe "elapsed days" comparison between any 2 dates, in the manner required by your system (i.e. sometimes if the starting and ending date are the same, you'd want to return a value of "1" instead of "0", in other words doing an "end dates inclusive" value).  For example the following:

    /* RULE_CalculateElapsedDays */
    /* Takes a Start and End date and calculates total elapsed (i.e. deployed) days,
      inclusively -- e.g. if the start and end date are the same day,
      the total elapsed days will be 1 instead of 0. */
    
    if(
      or(
        a!isNullOrEmpty(ri!startDate),
        a!isNullOrEmpty(ri!endDate)
      ),
      tointeger(null()),
      
      tointeger(ri!endDate - ri!startDate) + 1
    )

Reply
  • 0
    Certified Lead Developer

    I find it helpful to create an Expression Rule in my environments that can do a null-safe "elapsed days" comparison between any 2 dates, in the manner required by your system (i.e. sometimes if the starting and ending date are the same, you'd want to return a value of "1" instead of "0", in other words doing an "end dates inclusive" value).  For example the following:

    /* RULE_CalculateElapsedDays */
    /* Takes a Start and End date and calculates total elapsed (i.e. deployed) days,
      inclusively -- e.g. if the start and end date are the same day,
      the total elapsed days will be 1 instead of 0. */
    
    if(
      or(
        a!isNullOrEmpty(ri!startDate),
        a!isNullOrEmpty(ri!endDate)
      ),
      tointeger(null()),
      
      tointeger(ri!endDate - ri!startDate) + 1
    )

Children
No Data