You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Difference between DateTime fields

edited Aug 27, 2019 11:00AM in Sales 1 comment

Summary

Difference between DateTime fields

Content

We have two DateTime fields - Start Date & Time and End Date & Time

Based on Lookup value in another field we need to subtract these dates as conditions below

  1. If LOV is "By Day" - Calculate number of days between these two datetime fields
  2. If LOV is "By Hour" - Calculate number of hours between these two datetime fields

Version

19C

Code Snippet

def StartDate = getAttribute('StartDateTime_c')
def EndDate = getAttribute('EndDateTime_c')
def diff
if ((TripType_c=="By Day")|| (TripType_c=="By Hour"))
{
  diff = EndDate - StartDate
  setAttribute('NumberOfHoursDays_c',diff)
}
return false

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!