Skip to main content
Community site session details

Community site session details

Session Id : dw6ASGQeQTHan7Eym/nsL2
Power Apps - Building Power Apps
Answered

Data Validate for Date Text field and Time Text field

Like (0) ShareShare
ReportReport
Posted on 12 Aug 2021 14:47:10 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!

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    on 13 Aug 2021 at 02:48:58
    Re: Data Validate for Date Text field and Time Text field

    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.

  • pchristou Profile Picture
    14 on 12 Aug 2021 at 20:46:06
    Re: Data Validate for Date Text field and Time Text field

    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.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on 12 Aug 2021 at 18:10:00
    Re: Data Validate for Date Text field and Time Text field

    @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. 

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1

Loading complete