#1

Hi everyone!
I have a simple DATETIME_DIFF field that returns the amount of difference in dates just fine.
I however use it to count the days of an event and would like it to return the amount of days an event takes place, which then means I would need a DATEADD +1.
For some reason I just can’t get it to work properly. It’s probably as simple as a , but still.

This is what I’m trying to build from

``````IF(
{End Date}=BLANK(),
'1 day',	IF(
{End Date},DATETIME_DIFF({End Date}, {Start Date}, 'days') & ' dagar '))
``````

I am beyond greatful for any and all help I can get.

0 Likes

#2

You don’t need DATEADD; since DATETIME_DIFF returns an integer you can simply add 1:

``````IF(
{End Date}=BLANK(), '1 day',
IF(
{End Date}, DATETIME_DIFF({End Date}, {Start Date}, 'days') +1 & ' dagar '
)
)
``````

You can also simplify the formula to

``````IF(
{End Date},
DATETIME_DIFF({End Date}, {Start Date}, 'days') +1 & ' dagar ',
'1 day'
)
``````

As a side note, if you want to know how to fit DATEADD into DATETIME_DIFF:

``````DATETIME_DIFF(DATEADD({End Date},1,'day'),{Start Date},'days')
``````
2 Likes

#3

Thank you so much!
Thank you for simplifying the formula as well.
You answered it all with your examples and I now know for possible future use how to do it on my own.
Thank you!

1 Like