web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

DateValue Issue

(0) ShareShare
ReportReport
Posted on by 2,129

Content migrated from TechNet. Post attribution to:PK Hong

 

I am using DateValue(Text(Today()), "fr"), as well as "da", "zh-TW".

All are showing 1/2/2017, except "en" and "zh-CH" showing 2/13/2016 (this is correct today).

Please check is there is something wrong with Language_code.

TQ


PK Hong

Categories:
I have the same question (0)
  • Migrated_User Profile Picture
    2,129 on at

    The issue is that you're trying to parse a date in the incorrect format. I'm assuming your computer is in a configuration where the date format is set to mm/dd/yyyy, so the result of Text(Today()) is going to be "2/13/2016" (assuming that "Today" is February 13th, 2016).

    Now, if you try to convert that string to a date using the French format (which is dd/mm/yyyy), you will have the following components:

    • day: 02
    • month: 13
    • year: 2016

    That date is invalid (there are only 12 months in the year), so the function DateValue is doing its best to convert that to a date, assuming that the 13th month of 2016 is actually January 2017, and you'll end up with January 2nd, 2017 as your date value. And that's what you end up with in most of the language codes, since most countries use the dd/mm/yyyy format.


    Carlos Figueira

  • Migrated_User Profile Picture
    2,129 on at

    The issue is that you're trying to parse a date in the incorrect format. I'm assuming your computer is in a configuration where the date format is set to mm/dd/yyyy, so the result of Text(Today()) is going to be "2/13/2016" (assuming that "Today" is February 13th, 2016).

    Now, if you try to convert that string to a date using the French format (which is dd/mm/yyyy), you will have the following components:

    • day: 02
    • month: 13
    • year: 2016

    That date is invalid (there are only 12 months in the year), so the function DateValue is doing its best to convert that to a date, assuming that the 13th month of 2016 is actually January 2017, and you'll end up with January 2nd, 2017 as your date value. And that's what you end up with in most of the language codes, since most countries use the dd/mm/yyyy format.


    Carlos Figueira

  • Verified answer
    Migrated_User Profile Picture
    2,129 on at

    I'm afraid the advice on the other post you mentioned is misleading. We should not be using DateValue to format a date to be displayed for a specific locale. DateValue is used to convert from a text value to a Date/Time value - and what you want to do is exactly the opposite (convert from Date/Time to a text to be displayed). 

    If you want to display a date in a specific format, you should use the Text function, as you mentioned that it worked for you:

    Text(Today(), "dd/mm/yyyy")

    If you want to take a user's input (from a text input, for example), and convert it to a Date/Time value (e.g., to manipulate that value, to send it to aa function that expects a date, etc.), then you should use the DateValue function

    "30 days from today: " &
     Text(DateAdd(Today(), 30, Days), "dd/mm/yyyy")

    Carlos Figueira

  • Community Power Platform Member Profile Picture
    on at

    Hi @Migrated_User

    I'm able to add a DefaultDate using the formula:  Text(Today(), "mm/dd/yyyy" )

    and the date displays correctly, albeit in U.S. format  (e.g. 3/27/2017)

     

    As soon as I change the formula to:  Text(Today(), "dd/mm/yyyy" )

    the date becomes incorrect (e.g. 3/3/2019).

     

    When I click back on the date field, the DefaultDate formula has changed to include a [$-en-US] value:

     

    dateInput.png

     

    Is there anyway to stop this from happening?  Thank you!

  • AndyPennell Profile Picture
    on at

    DefaultDate requires an actual date, and you are giving it a string, which it is trying to re-interpret (subject to your locale). Just set it to

    Today()

    if you would like it to default to the current day.

     

    The format of the date shown in the picker is determined by the locale the app is running in.

  • AndyPennell Profile Picture
    on at

    FYI the date picker displays the date using the equivalent of

    Text(date,DateTimeFormat.ShortDate)

    which will display in a format dependent on the current locale.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard