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

Calculate week number, weekday, month eg.

Im using a model drive app.  In the Entity there is a data Field: Orderdate.   The order day today is 4.11.2020 (November, 4th - Norwegian format)

 

I like to add Fields With week number, day in week, day in week in text (Wednesday) and also month name. 

 

Orderdate: 4.11.2020

Week number: 45

Day in week: 3 (starts With 1 on monday)

Weekdayname: Wednesday

Monthname: November

 

Any idea how this values can be added to the actual Field based on "Order date"?

(It seems easy in Canvas app", but only model driven app is in use. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @TrulsB :

It can be inplemented with flow.I'v made a test for your reference:

1.JPG

Formula reference:

Switch On:

dayOfWeek(triggerOutputs()?['body/crba2_orderdate'])

Day in week:

dayOfWeek(triggerOutputs()?['body/crba2_orderdate'])

Monthname:

formatDateTime(triggerOutputs()?['body/crba2_orderdate'],'MMMM')

Week number:

add(div(dayOfYear(triggerOutputs()?['body/crba2_orderdate']), 7),1)

Weekdayname:

Variables('WeekName')

2.JPG

Best Regards,

Bof

 

View solution in original post

5 REPLIES 5
ChrisPiasecki
Super User
Super User

Hi @TrulsB,

Unfortunately on model driven apps those same formulas are not available. Creating a plugin would be a good option, using the Calendar class of the .NET framework. 

Some useful references below:

https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/tutorial-write-plug-in

https://docs.microsoft.com/en-us/dotnet/api/system.globalization.calendar.getweekofyear?view=netfram...

---
Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

Hi, thank you !

Your suggestion seems be requiere knowledge in Visual Studio, C Programming eg.

Do you have any other suggestions? Do you know of somwhere to download plug-ins for week and day calculation? Any experience using Power Automate to do this calculations and update when a record is changed ?

v-bofeng-msft
Community Support
Community Support

Hi @TrulsB :

It can be inplemented with flow.I'v made a test for your reference:

1.JPG

Formula reference:

Switch On:

dayOfWeek(triggerOutputs()?['body/crba2_orderdate'])

Day in week:

dayOfWeek(triggerOutputs()?['body/crba2_orderdate'])

Monthname:

formatDateTime(triggerOutputs()?['body/crba2_orderdate'],'MMMM')

Week number:

add(div(dayOfYear(triggerOutputs()?['body/crba2_orderdate']), 7),1)

Weekdayname:

Variables('WeekName')

2.JPG

Best Regards,

Bof

 

View solution in original post

Thanks, perfecet !!

Just an additional question.  Everything Works well, but when i remove the date in the date Field in Model Drive app, and save - whe flow runs - but the Fields for Week number, days in week, weekday name eg is no cleared or reset. The values for the last date are still there, even if the date Field is empty.  Any idea how to handel this, so every Fields are empty of the Orderdate Field is empty. ?

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,358)