Skip to Content
author's profile photo Former Member
Former Member

Calculate date difference in SDK

Hello gurus,

I have to calculate difference between two dates in activities (Activity XBO): start date and end date.

This is what I have in the task:

This is how i see the data in debug mode for these fields:

this.ScheduledStartDate = 2016-12-14 (Date)

this.ScheduledEndDate = 2017-01-15 (Date)

this.ScheduledStartDateTime = 2016-12-14T12:30:00Z UTC BASIS.Global:LOCALNORMALISED_DateTime (GLOBAL_DateTime)

this.ScheduledEndDateTime = 2017-01-15T12:00:00Z UTC BASIS.Global:LOCALNORMALISED_DateTime (GLOBAL_DateTime)

Now, the difference of the dates is 32 (Delta between Dec 14th and Jan 15th). But when i use the following, the difference comes as 31


I tried other options of converting to global date time etc but i always get 31 and not 32. I know i am missing something. Any help is appreciated.



Add comment
10|10000 characters needed characters exceeded

1 Answer

  • Best Answer
    Posted on Mar 06, 2017 at 05:21 AM

    Hi Mahesh,

    It seems duration.ConvertToDays() returns 30 days for 1M.

    this.ScheduledEndDate.Delta(this.ScheduledStartDate) returns P1M1D.

    ConverToDays() returns 31 days (30 days for 1M plus 1 day for 1D).

    Luckily, there is another parameter you can pass to the Delta() method.

    The following will return the duration in days.

    var duration = this.StartDate.Delta(this.EndDate,true); // this will return 32 in your case

    Best Regards,


    Add comment
    10|10000 characters needed characters exceeded