Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

DateTime Controller Value Is Not Changing When The Toggle Value is True

(0) ShareShare
ReportReport
Posted on by 72

Hi All,

 

I have SharePoint List which has a form that customized using PowerApps.

 

In this form I have:

1. Date and Time controller - Email Draft Needed By (Date and time format - Date & Time)

2. Toggle - Same Day Due - Yes/No

 

Properties

Email Draft Neede By Card Name > Email Draft Needed By_DataCard1

Controller Name > dtpEmailDraftNeededBy

dtpEmailDraftNeededBy > DefaultDate

 

Same Day Due Card Name > Same Day Due_DataCard1

Controller Name > tglSameDayDue

 

I want to add few hours to the DefaultDate property of the Email Draft Needed By when the Same Day Due toggle is 'YES'.

 

I used the below formula

 

If(IsBlank(Parent.Default)&&tglSameDayDue.Value=false,Today()+1,If(IsBlank(Parent.Default)&&tglSameDayDue.Value=true,Text(DateAdd(Now(), 4, Hours),"dd-mm-yyyy hh:mm"),Parent.Default)) 

 

The issue is that this formula didn't add hours to Now().

 

Can someone please let me know what I have done wrong?

 

Thanks.

  • WarrenBelz Profile Picture
    146,631 Most Valuable Professional on at
    Re: DateTime Controller Value Is Not Changing When The Toggle Value is True

    Hi @chiranjay ,

    Firstly, if you are using this as a DefaultDate of a Date Picker, it has to be a date, so Text() will not work. Also Date fields are not necessarily blank so, try this (put in your Date Field name)

    With(
     {
     wDay: DateAdd(Today(),1,Days),
     wHour: DateAdd(Now(),4,Hours)
     },
     If(
     Value(ThisItem.YourDateFieldName) > 0,
     ThisItem.YourDateFieldName,
     tglSameDayDue.Value,
     wHour,
     wDay
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • ChiranJay Profile Picture
    72 on at
    Re: DateTime Controller Value Is Not Changing When The Toggle Value is True

    Apologies for the late reply.

     

    Unfortunately your solution didn't work @WarrenBelz 

     

    Could you please let me know what's wrong with the below function()

     

    If(IsBlank(Parent.Default)&&tglSameDayDue.Value=false,Today()+1,If(IsBlank(Parent.Default)&&tglSameDayDue.Value=true,Text(DateAdd(Now(), 4, Hours),"dd-mm-yyyy hh:mm"),Parent.Default)) 

     

    I have applied this function to the DefaultDate property of the Email Draft Needed By(DateTime Picker) when the Same Day Due toggle is 'YES'.

     

    This Email Draft Needed By DateTime Picker is configured to show the dates only from SharePoint list properties. To solve the hours issue, I'm using this part of the function 

     

    Text(DateAdd(Now(), 4, Hours)

     

     

    I can't figure out what I am missing in here.

     

    Thanks in advance.

  • WarrenBelz Profile Picture
    146,631 Most Valuable Professional on at
    Re: DateTime Controller Value Is Not Changing When The Toggle Value is True

    Hi @chiranjay ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • WarrenBelz Profile Picture
    146,631 Most Valuable Professional on at
    Re: DateTime Controller Value Is Not Changing When The Toggle Value is True

    Hi @chiranjay ,

    Is Parent.Default a Date ? If so you need

    With(
     {
     wDay: DateAdd(Today(),1,Days),
     wHour: DateAdd(Now(),4,Hours)
     },
     Coalesce(
     Parent.Default,
     (!tglSameDayDue.Value && wDay) || wHour
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,631 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,991 Most Valuable Professional

Leaderboard