cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper IV
Helper IV

How to display "Day" and "Days" text when using DateDiff

Hi,

 

I am calculating date difference using below formula. Below formula shows the difference between dates and add text "Day" to the DataCard. For Ex: Datediff between 01Mar-01 Mar = "1 Day" gets displayed on DataCard. However, Let's say if the date difference is more than 1 day, then I would like to display text "Days" instead of "Day". Ex: 01 Mar-02 Mar= 2 Days should get displayed in the DataCard. I am not sure how to achieve this ?

 

DateDiff(DatePicker1.SelectedDate,DatePicker1_1.SelectedDate)+1 & " Day"

 

Thanks in advance for your time!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

@Newbie12 

Please consider changing your Formula to the following:

With({_diff: DateDiff(DatePicker1.SelectedDate,DatePicker1_1.SelectedDate)+1},
    _diff & " Day" & If(_diff<>1, "s")
)

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

3 REPLIES 3
Memorable Member
Memorable Member

Try

DateDiff(DatePicker1.SelectedDate,DatePicker1_1.SelectedDate)+1 & If(DateDiff(DatePicker1.SelectedDate,DatePicker1_1.SelectedDate)+1 >1," Days"," Day"))

 

Super User III
Super User III

@Newbie12 

Please consider changing your Formula to the following:

With({_diff: DateDiff(DatePicker1.SelectedDate,DatePicker1_1.SelectedDate)+1},
    _diff & " Day" & If(_diff<>1, "s")
)

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Helper IV
Helper IV

Thank you @RandyHayes @leyburn19 both solution seem to work fine!

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (51,046)