Difference between DateTime fields
Summary
Difference between DateTime fieldsContent
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
- If LOV is "By Day" - Calculate number of days between these two datetime fields
- If LOV is "By Hour" - Calculate number of hours between these two datetime fields
Version
19CCode 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
Tagged:
1