How can I calculate the number of days based on start date and end date using Groovy?

You can use this Groovy sample script to calculate the number of days for your sales object:

def Number of days = day(EndDate) - day(StartDate)

The script uses the EndDate and StartDate attributes to calculate the difference.