Day Difference Date Time Operators

  • 14 March 2016
  • 4 replies
  • 4 views

Badge +1

I am new to K2 dev and I am getting a date  Difference for a data label expression and it seems to be off one day. When I use the same dates in Excel or in another web application I get the same value but K2 shows one day less.

 

4/1/2015 to 8/4/2016 gets 490 days.  Everywhere else gets 491. 

 

I have tried other date ranges and the day count is correct.  One theory in our office was 2016 is a leap year.

 

Anyone have any thoughts on this method in K2 or seen this issue and no how to work around or fix?

 

Thanks.

 

Jason


4 replies

Badge +6

If you are using a sharepoint list, there is a simple formula for the date field to get the difference between 2 dates. You can use that instead.

 

Also, is server date and time ok?

Badge +1

These 2 date fields are coming from a sql database.  I could add a calculated column there as well, I just think it is interesting that the out of box functions have different results then everything else I use to calculate days between dates.

 

Thanks for the help.

Userlevel 3
Badge +10

@JasonD1 I believed I have figured out what's wrong; you were right about the leap year being the issue.  When calculating Day Difference within a leap year, values appear to return correctly, but when 'crossing into' another year, the calculation appears to forget that there was a leap year involved. See the following:


 


16175i405E858D583814F7.png


 


Probably best to calculate this via a Web Service call or another source outside of SmartForms.


 


Regards,


Jonathan

Badge +1

@JonathonT I am logging this as a bug with K2 so that we can get this fixed.  Basic .Net functions that should work correctly for a fancy forms tool.

 

Thanks for your advice.

Reply