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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Data Validate for Date...
Power Apps
Answered

Data Validate for Date Text field and Time Text field

(0) ShareShare
ReportReport
Posted on by 14

Good afternoon,

I have this data validation that another member of the community suggested for my data that works perfectly (And a big thank you to the guy!) :

If(!IsMatch(DataCardValue37.Text,"\d{4}-\d{2}-\d{2}"),
Notify("Please input date in YYYY-MM-DD format!",NotificationType.Error)
)

However, I would like to modify it so that each digit is within a certain range. For example, the first digit of the year should always be a 2 while the second should be 0 and for example, the first digit of the month should always be a 0 or a 1 and for the day 0, 1, 2, or 3. I just wanted to give you a couple of examples to understand the kind of data validation I would like for individual digits.

Any suggestions?

Thank you in advance!

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @pchristou 

    I suggest that you use a datepicker for dates and 2 dropdowns for hours and minutes respectively.  This way you can control how the user inputs date and time data. see @CarlosFigueira 's solution here:   https://powerusers.microsoft.com/t5/Building-Power-Apps/Date-hour-minute-picker-current-date-hour-and-minute/td-p/119799 

    The less flexibility you give users with regard to entering data the better. 

  • pchristou Profile Picture
    14 on at

    I have a lot of trouble with date pickers when I try to pass the value in as text for some reason and that is why I made it a text field.

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @pchristou,

    What a coincidence!

    Do you want to validate the certain date format using regular expression?

    Please modify your formula as below:

    If(
     !IsMatch(
     DataCardValue37.Text,
     "[2]\d{3}-(0[1-9]|1[0-2])-[0-3]\d{1}"
     ),
     Notify("Please input date in YYYY-MM-DD format!",NotificationType.Error)
    )

    Here is the explanation of splitting one by one:

    [2]\d{3} // The first digit always starts with 2,so the left number of digits you could input is 3 instead of 4 
    (0[1-9]|1[0-2])// The month digit always starts with 0 or 1
    [0-3]\d{1}// The day digit always starts with 0, 1, 2, or 3

    Hope we could solve this successfully as before.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 893

#2
Valantis Profile Picture

Valantis 571

#3
11manish Profile Picture

11manish 482

Last 30 days Overall leaderboard