cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

Challenging Date Issue

Does anyone know how to perform something like: 

 

If( datepicker.SelectedDate = 1st -9th of the month, 

do this,

else do this) 

 

?

 

I can't figure out how to determine the date of the month from the datepicker. Any help is appreciated. 

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Community Champion
Community Champion

Hi @ericonline,

 

This is a fun question. It sounds like you want a condition to determine if the date in the datepicker is between a certain range. 

 

The Date() function can name a date that you can use for comparison.

 

In your case, you'll need two conditions met:

  • compare to see if the date is later than 1st of the month
  • compare to see if the date is earlier than the 9th of the month

 

Your condition might look like this:

If(
  And(
    datepicker.SelectedDate>=Date(Year(Today()), Month(Today()), 1),
    datepicker.SelectedDate<Date(Year(Today()), Month(Today()), 9+1)
  ),
  
  do this,
  else do this
)

This means, "If the selected date in the datepicker is later than or on the first of the month--AND--earlier than or on the 9th, do this, else do that."

 

In blue, I created a date to compare against by using the Date() and Today() functions. It takes today's date and extracts the year and month from it. I specify the day according to need. If you need to compare it to the 1st and 9th of another month, you can change it to your needs, but this will give you a start.

 

Note that I added 1 to the 9th date and made the comparison less than just in case it was not inclusive. I'd test this out on your end to be sure.

 

Let me know if this is helpful with a thumbs up.

 

Mr. Dang

_______

Microsoft Employee
@8bitclassroom

View solution in original post

5 REPLIES 5
Community Champion
Community Champion

Hi @ericonline,

 

This is a fun question. It sounds like you want a condition to determine if the date in the datepicker is between a certain range. 

 

The Date() function can name a date that you can use for comparison.

 

In your case, you'll need two conditions met:

  • compare to see if the date is later than 1st of the month
  • compare to see if the date is earlier than the 9th of the month

 

Your condition might look like this:

If(
  And(
    datepicker.SelectedDate>=Date(Year(Today()), Month(Today()), 1),
    datepicker.SelectedDate<Date(Year(Today()), Month(Today()), 9+1)
  ),
  
  do this,
  else do this
)

This means, "If the selected date in the datepicker is later than or on the first of the month--AND--earlier than or on the 9th, do this, else do that."

 

In blue, I created a date to compare against by using the Date() and Today() functions. It takes today's date and extracts the year and month from it. I specify the day according to need. If you need to compare it to the 1st and 9th of another month, you can change it to your needs, but this will give you a start.

 

Note that I added 1 to the 9th date and made the comparison less than just in case it was not inclusive. I'd test this out on your end to be sure.

 

Let me know if this is helpful with a thumbs up.

 

Mr. Dang

_______

Microsoft Employee
@8bitclassroom

View solution in original post

Thank you for the detailed assistance @mr-dang, I really appreciate it. 

 

I'm still missing something. 

 

I'm trying to create a URL based on the datePicker.SelectedDate. The final URL depends on the function:

Text(datePicker.SelectedDate, "[$-en-US]xx_xx_xxxx"),

If the datePicker.SelectedDate is: 

Single digit month, then m_xx_yyyy.

Double digit month, then mm_xx_yyyy

Single digit day, then xx_d_yyyy

Double digit day, then xx_dd_yyyy

 

Here is what I have so far, but the And statement isn't producing the correct format when 7-1-2018 is the SelectedDate. (its producing 7_01_2018.)

Concatenate("https://ourcompany.sharepoint.com/teams/MEC/docRepo/Forms/AllItems.aspx#id=%2Fteams%2FMEC%2FdocRepo%2F",
    dropdown.Selected.Result, "-", 
    peoplePicker.Selected.Value, "-", 
    If(
        And(
            datePicker.SelectedDate = Date(Year(Today()), Month(Today()), 1),
            datePicker.SelectedDate > Date(Year(Today()), Month(Today()), 9+1)),
    Text(datePicker.SelectedDate, "[$-en-US]m_d_yyyy"),
    Text(datePicker.SelectedDate, "[$-en-US]m_dd_yyyy")
    ),
    "%2Epdf&parent=%2Fteams%2FMEC%2FdocRepo")

Hope this is clear. 

Awesome. I was able to get the correct URL by using <= 9 in place of the And statement. I think this will work. 

 

I'll still need to play with the single/double digit month piece, but should be good now. Thank you for showing me how to use the Date() function. That will be useful moving forward. 

 

Concatenate("https://ourcompany.sharepoint.com/teams/MEC/docRepo/Forms/AllItems.aspx#id=%2Fteams%2FMEC%2FdocRepo%2F",
   dropdown.Selected.Result, "-", 
    peoplePicker.Selected.Value, "-", 
    If(
        datePicker.SelectedDate <= Date(Year(Today()), Month(Today()), 9),
        Text(datePicker.SelectedDate, "[$-en-US]m_d_yyyy"),
        Text(datePicker.SelectedDate, "[$-en-US]m_dd_yyyy")
    ),
    "%2Epdf&parent=%2Fteams%2FMEC%2FdocRepo")

Ah, I understand now. I'm glad you were able to resolve it 🙂

 

I am thinking you can even skip the condition altogether and use:

Text(datePicker.SelectedDate, "[$-en-US]m_d_yyyy")

Even though m and d are 'single,' they will show all digits for the respective month and day. Does that work for your URL?

Microsoft Employee
@8bitclassroom

Sweet! That did indeed work (and simplified things a bit). Good little piece of info to know. 

 

Thanks again and look forward to seeing you at the upcoming MS Business App summit in Seattle!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (9,528)