In this Power Apps tutorial, We will discuss how to get month name from date using Power Apps Datepicker control.
I was recently working in the Power Apps DatePicker control and needed to get the month name from a specific date. Along with that, I will show you how to get the month name including year in PowerApps.
Get month name from date in Power Apps
Here, we will see how to get the month name from a date in Power Apps Datepicker. Let’s get started with this.
Requirement:
- In the screenshot below, you can see there is a Power Apps Edit form named Employee Registration Form.
- Within the form, we can view several fields (Employee Name, Contact, etc.) along with a Date field named Join Date. All the fields are retrieved from a SharePoint list.
- The user will now enter the Join Date along with the other entries in the Power Apps form. The month name will be extracted from the selected date when the user chooses a specific date from the date picker control.
- For example, When I selected the Join Date as 1/6/2023, the month is retrieved as January from that specific date chosen as shown below.
Now follow the instructions below to achieve this.
As I mentioned above, the Power Apps form fields are retrieved from the SharePoint list, so the below screenshot represents the SharePoint list (i.e., Employees) having various columns. Such as:
- Employee Name: People types
- Address: Single-line text
- Contact: Number
- Join Date: Date type column
- Department: Choice column (i.e., IT, Finance, HR, Manager)
- Manager: Single line of text
- On the Power Apps environment, build a blank canvas app.
- On that canvas app, add a Power Apps edit form.
- Connect that edit form to the above-mentioned SharePoint list (i.e., Employees)as the data source. We can see all the fields will retrieve from the SharePoint list to edit form as below:
DataSource = Employees
Also, we can see the Join Date DataCard will come with a date picker control, as shown below: (We have selected a date from the Join Date picker control)
As per the requirement, we need to get the month’s name from the selected date. That means if the user selects a date as “1/06/2023,” then it will display the month’s name as “January” in a label control.
For this, the following steps are:
- Select the Join Date Data Card inside the edit form and unlock it to change the properties.
- Add a label control inside the DataCard and place it under the date picker control.
- Insert the below expression on the label’s Text property to display the month’s name from the selected date.
Text = "The joining month is " & Text(DataCardValue3.SelectedDate, "[$-en-US]mmmm")
where DataCardValue3 is the name of the data card value of the Join Date data card. To display only the month’s name, we have used “mmmm.”
Let’s preview the app and select a date from the date picker control (ex: 4/26/2023) as well as fill in all the details (optional). We can see it will display the respective month (i.e., April) as below:
This is how to get the month name from the date field within the Power Apps.
How to display month name and year in Power Apps?
Similarly, we can display both the month name and year from the selected date within the Power Apps at the same time.
To achieve this requirement, I am going to use the above example of the Power Apps edit form and the following steps are:
- On the above Power Apps edit form, select the label control under the Join Date DataCard.
- Insert the below expression on the Label’s Text property.
Text = "The joining month-year is " & Text(DataCardValue3.SelectedDate, "[$-en-US]mmmm yyyy")
Once the above formula is applied, we can see the month name and year will be extracted from the selected date and displayed on the label control.
This is how to display the month name and year in the Power Apps.
Conclusion
From this Power Apps Tutorial, we discussed how to get the month name from the date in Power Apps and how to display the month name with the year from the Power Apps date data card.
You may also like the below power apps tutorials:
- How to Reset Power Apps Date Picker
- How to Patch Power Apps Date Picker
- How to disable Power Apps date picker
- How To Set Default Date in Power Apps Date Picker
- Power Apps Filter With Date Picker
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.