cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Viipiin
Frequent Visitor

Facing challenges with my date start for time tracking

Hi Everyone, 

This is my first post here. 

I'm going through with a requirement where I have to make a time tracker but the gotcha is that every time a user select a month it must start with 1st of every month and dynamically add days names on canvas. It should be divided in weeks like 1-7 week1 8-14 week2 and so on and left days at the end should be counted as last week of that months like date 29 and 39 will be in that month.

 

This approach is little tedious for me bcoz I'm newbie in Power Apps. 

 

Any suggestion would be highly appreciated. 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @Viipiin :

Could you tell me:

  • Do you want to get a complete list of dates of the month by selecting a month?
  • Whether to mark the 1-7th of each month as "Week1" and "8-14 as Week2"...?

I'v made a test for your reference:

1\Add two TextInput controls(TextInput3/TextInput4)

2\Try this code:

ForAll(
    [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],
    If(
        Month(
            DateAdd(
                Date(
                    Value(TextInput3.Text),
                    Value(TextInput4.Text),
                    1
                ),
                Value,
                Days
            )
        ) = Value(TextInput4.Text),
        {
            Date: DateAdd(
                Date(
                    Value(TextInput3.Text),
                    Value(TextInput4.Text),
                    1
                ),
                Value,
                Days
            ),
            Week: If(
                Value < 7,
                "Week1",
                Value < 14,
                "Week2",
                Value < 21,
                "Week3",
                Value < 28,
                "Week3",
                "Week4"
            )
        }
    )
)

8.gif

Best Regards,

Bof

View solution in original post

1 REPLY 1
v-bofeng-msft
Community Support
Community Support

Hi @Viipiin :

Could you tell me:

  • Do you want to get a complete list of dates of the month by selecting a month?
  • Whether to mark the 1-7th of each month as "Week1" and "8-14 as Week2"...?

I'v made a test for your reference:

1\Add two TextInput controls(TextInput3/TextInput4)

2\Try this code:

ForAll(
    [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],
    If(
        Month(
            DateAdd(
                Date(
                    Value(TextInput3.Text),
                    Value(TextInput4.Text),
                    1
                ),
                Value,
                Days
            )
        ) = Value(TextInput4.Text),
        {
            Date: DateAdd(
                Date(
                    Value(TextInput3.Text),
                    Value(TextInput4.Text),
                    1
                ),
                Value,
                Days
            ),
            Week: If(
                Value < 7,
                "Week1",
                Value < 14,
                "Week2",
                Value < 21,
                "Week3",
                Value < 28,
                "Week3",
                "Week4"
            )
        }
    )
)

8.gif

Best Regards,

Bof

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,206)