Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Date Expression - Text Label vs. Text Input?

(0) ShareShare
ReportReport
Posted on by 987

I have used the same function for a text label and a text input control. But the returned values are different. I have two questions:

 

1. Why are the formats different if the expression is the same? (The only difference with the top one is that it has a prefix of
"Date/Time: " & ) - I literally copied the expression from the top text box to the bottom one, and only deleted the prefix.
See screen shot below to understand what I mean by variance :
--Label has regular time,
--Input Box has military time, and
--Label has AM PM and Input Box doesn't

2. Is there anything special I need to do in order to submit the input value (bottom one shown in image) to a date column in SharePoint (right now it doesn't seem to be working)?

 

Notes:

--We are using these dates to log items from paper (so we can't use created and modified times on SharePoint)

--I'm not using the Power App templates, I'm patching the data down to SharePoint. i.e. Patch() function.

 

Thank you in advance for your help.

 

Time Variance.PNG

  • audrieFCT Profile Picture
    audrieFCT 987 on at
    Re: Date Expression - Text Label vs. Text Input?

    That works perfectly Andy!! Thanks so much to both of you.

  • rgruian Profile Picture
    rgruian on at
    Re: Date Expression - Text Label vs. Text Input?

    What Andy pointed out is correct. string & date will coerce the right hand side (a date numeric value) to a string using a predefined format. If you need to use a specific format, you need to perform that projection from date/value to text yourself.

     

    In the label:

    "Date/Time: " & Text(Now(), "mm/dd/yyyy hh:mm:ss")

     

     

  • audrieFCT Profile Picture
    audrieFCT 987 on at
    Re: Date Expression - Text Label vs. Text Input?

    LOL - that's funny because that is the one that was working as I expected! Let me try that and see if I now have two problems.

     

    Thank you - will post back here as soon as I give it a try.

  • Verified answer
    AndyPennell Profile Picture
    AndyPennell on at
    Re: Date Expression - Text Label vs. Text Input?

    The Label one needs to do the concatenation outside the Text function:

    "Date/Time: " & Text(Now(), "mm/dd/yy hh:mm:ss am/pm")

     

    Now() is not a string: it returns a date. Whenn you add it to the string it converts it and loses its "date-ness".

  • audrieFCT Profile Picture
    audrieFCT 987 on at
    Re: Date Expression - Text Label vs. Text Input?

    Here are the two expressions my apologies for being unclear. These expressions plus the screen shot should further clarify:

     

    In the label:

    Text( "Date/Time: " & Now(), "mm/dd/yyyy hh:mm:ss" )

     

    In the Text Input Box (Default value that the consumer of the form can edit):

    Text(Now(), "mm/dd/yyyy hh:mm:ss" )

     

     

     

  • rgruian Profile Picture
    rgruian on at
    Re: Date Expression - Text Label vs. Text Input?

     

    Can you please list here the exact expressions for your two controls? I can see one of them, the other one is unclear to me.

     

    One thing to note is that date/time values in PowerApps are not text/strings. They are numeric, and flow through the dataflow graph from / into controls as such. At the point where they need to be presented in text form, they are projected to strings. This typically happens in one of three main ways:

     

    1. Explicit projection using the Text function. The format is specified in the formula. E.g. label.Text = Text(dt, "mm/dd/yyyy hh:mm a/p")

    2. Implicit projection via type coercion from date/time to text. The format is fixed and culture-specific. For en-US, it's typically "mm/dd/yyyy hh:mm:ss a/p". For example: label.Text = Now()

    3. Implicit projection by a control that manipulates date/time values. An example would be a calendar control.

     

    I am trying to understand what your formulas are, so I can see which of these cases actually kick in (in your case).

     

     

    Regarding your second question, I suspect the date/time value for SharePoint needs to be properly typed. You should be able to use the DateTimeValue or DateValue functions (as appropriate) to convert text, for example from a TextInput control, to a date/time value compatible with SharePoint.

  • AndyPennell Profile Picture
    AndyPennell on at
    Re: Date Expression - Text Label vs. Text Input?

    If you always want 12-hour time in US format, use a formula of Text(Now(),"mm/dd/yyyy hh:mm:ss am/pm")

     

    I cannot explain why one is different to the other though, I get 24-hour time by default for both on my machine.

     

    (Sorry I dont know anything about submitting dates to SP).

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,343

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,703

Leaderboard