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

How to get the date of the day selected on Drop Down

Hi Experts,

Would like to seek your help on how I can get the date of the selected day in the DropDown, so the date should be the following week Monday, Tues etc...

or How I can auto fill the dropdown automatically with the Day and date the following week, sample dropdown will show Mon (18 Jan), Tues (19 Jan) etc instead of just Monday, Tuesday, ....  if this is possible (This is the solution I prefer), no need to show the date as mentioned aboved.

 

Note that this dropdown is from a SharePoint List, and the selection on this will be save in the SharePoint List after clicking submit.

date33.PNG

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

In terms of code it could look something like this:

 

Put this for example on visible of the screen

Set(VarStartDate,
If(
    Weekday(Today()) = 1, Today()+1,
    Weekday(Today()) = 7, Today()+2,
    Weekday(Today()) = 6, Today()+3,
    Weekday(Today()) = 5, Today()+4,
    Weekday(Today()) = 4, Today()+5,
    Weekday(Today()) = 3, Today()+6,
    Weekday(Today()) = 2, Today()+7
)
)

;

ClearCollect(ColDropdown, 
{Results: "Monday - " & VarStartDate},
{Results: "Tuesday - " & VarStartDate+1},
{Results: "Wednesday - " & VarStartDate+2},
{Results: "Thursday - " & VarStartDate+3},
{Results: "Friday - " & VarStartDate+4}
)

 

And then put ColDropdown as items for your dropdown menu.

 

Screenshot attached (Date is formatted in german, but using the code above should default it to whatever language you are running your powerapps in)

View solution in original post

5 REPLIES 5
_Nils_
Advocate I
Advocate I

Hi @Champ14 

if you just want to select a day, I would suggest using a datepicker instead of a dropdown. Does that work for you?

Champ14
Helper I
Helper I

Hi @_Nils_ ,

It is eactually what I initially do, and I just create a restriction parameters on the submit button if they selected a date outside of the booking period, but management preferred it to be this way... Will this be possible or not at all?

I also thought to just only show the upcoming week but based on my search it will not be possible as well.

Hi @Champ14 

I don't really know, what happened here, I posted a reply a couple of hours ago, but somehow it's not here anymore. So here we go again:

 

Using the "Weekday" function you can find out which weekday a particular date is. So Weekday(Today()) results in a number, correlating to a particular day. So 1=Sunday, 2=Monday, 3=Tuesday etc.

 

You could then create a collection with ne numbers from 1-7 in one column and the names of the days in another. This way you could use the "LookUp" function to match the number to the name of the day.

 

That should solve your first requirement: Name and date of a particular day.

 

Next thing we need to figure out is how to calculate what date is the start of the next week.

The only way i can think of right now to do that is:

 

Create conditions for each weekday. So if today is Sunday, then the date you need is Today()+1. If today is Saturday then you need Today()+2 etc. This gives you the start date for your dropdown.

 

Finally you should only have to add the number of days you want to display to that start date (maybe 5, maybe 7, depending on what you need).

 

I hope that gets you close to what you need.

In terms of code it could look something like this:

 

Put this for example on visible of the screen

Set(VarStartDate,
If(
    Weekday(Today()) = 1, Today()+1,
    Weekday(Today()) = 7, Today()+2,
    Weekday(Today()) = 6, Today()+3,
    Weekday(Today()) = 5, Today()+4,
    Weekday(Today()) = 4, Today()+5,
    Weekday(Today()) = 3, Today()+6,
    Weekday(Today()) = 2, Today()+7
)
)

;

ClearCollect(ColDropdown, 
{Results: "Monday - " & VarStartDate},
{Results: "Tuesday - " & VarStartDate+1},
{Results: "Wednesday - " & VarStartDate+2},
{Results: "Thursday - " & VarStartDate+3},
{Results: "Friday - " & VarStartDate+4}
)

 

And then put ColDropdown as items for your dropdown menu.

 

Screenshot attached (Date is formatted in german, but using the code above should default it to whatever language you are running your powerapps in)

View solution in original post

Champ14
Helper I
Helper I

Thank you @_Nils_ !!!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (29,951)