how to write regular expression for Date field?

Answers were Sorted based on User's Feedback



how to write regular expression for Date field?..

Answer / raghu

To apply Regular expression for Date we have to split months
1) [0][1-9] because it accepts 01,02,...09 as months

2) [1][1-2] and this is for 10th,11th, 12th months

Now The Regular expression for whole date format is as follows

Example MM/DD/YY

[0][1-9][/][0-9][0-9][/][0-9][0-9] for 1 to 9 months
[1][1-2][/][0-9][0-9][/][0-9][0-9] for 10 to 12 months

Is This Answer Correct ?    0 Yes 0 No

how to write regular expression for Date field?..

Answer / ratikanta

[0][1-9]|[1-2][0-9]|[3][0-1]-[0][1-9]|[1][0-2]-[1-9][0-9][0-9][0-9]

Is This Answer Correct ?    0 Yes 0 No

how to write regular expression for Date field?..

Answer / naresh

30/12/12 format


(0-3)(0-3)/(0-1)(0-9)/(0-9)(0-9)

Is This Answer Correct ?    0 Yes 0 No

how to write regular expression for Date field?..

Answer / biswarup

dd-mm-yy format then it will be

[[0-3][0-9]]&&[^3[2-9]^00]-[[01][0-9]]&&[^1[3-9]^00]-\d{2}

please rectify me if you find it to be incorrect or with
some minor error, as i'm not completely sure about the part
after '&&', i mean, the error is not in the logic but in the
syntax of using the AND and OR operators.

Is This Answer Correct ?    7 Yes 8 No

how to write regular expression for Date field?..

Answer / rajesh

[1-9]|1[0-2]/[1-9]|[1-2][0-9]|3[0-1]/19[0-9][0-9]|2[0-9][0-9][0-9]

This works for 1900 to 2999

Is This Answer Correct ?    0 Yes 1 No

how to write regular expression for Date field?..

Answer / rajesh vanamala

MM/DD/YYYY

[0][1-9]|[1][0-2]/[0][1-9]|[1][0-9]|[2][0-9]|[3][0-1]/[1-9][0-9][0-9][0-9]

Is This Answer Correct ?    1 Yes 2 No

how to write regular expression for Date field?..

Answer / a kiran kumar

for example date formate is dd/mm/yy
than [0-3][0-9]/[0-1][0-2]/[0-9][0-9]

Is This Answer Correct ?    14 Yes 18 No

how to write regular expression for Date field?..

Answer / sow

[0-3][0-1]/[0-1][0-2]/200[0-9]

This would take only 2001 to 2009. It will not accept 1999.

Is This Answer Correct ?    2 Yes 7 No

how to write regular expression for Date field?..

Answer / ashok

For example date format is dd/mm/yy

than [0-3][0-9]/[0-1][0-9]/[0-9][0-9]

Is This Answer Correct ?    4 Yes 15 No

how to write regular expression for Date field?..

Answer / satyanarayana

If the date field is in the following format

'mm/dd/yy'
[0-1][0-9]/[0-3][0-9]/200[0-9]

Is This Answer Correct ?    4 Yes 17 No

Post New Answer

More QTP Interview Questions

Write the code for select the 5 values from drop down list. drop down list having the 10 values.

6 Answers  


If there r 1000 test scripts that were written. If a change to any functionality is to be made then how can we know in which script is this functionality existing.

4 Answers   iGate,


I have recorded a test over web application(with IE6.0) in analog mode. But, while running it my test gets failed. Why? (Note: my systray has 3 open web applications)

1 Answers  


Hi, I am new to QTP testing and was exploring the frameworks used for automation. I wanted help in writing various scripts and files for keyword driven automation like 1. Control File 2. Test Case File 3. Startup Script 4. Driver Script 5. Utility Script . etc It would be great if someone can give help in this context ... Thanks

0 Answers  


I have a WebEdit Object.It is added in object repository.It has two properties Name and Index.In the next release the Name Property is same but the index property is changed.when i run the script will the script Pass or Fail

9 Answers   ADP,






What is the extention of Virtualobject

1 Answers   Accenture,


How to capture a window in qtp or how to take snapshot of any window while writing script in qtp

3 Answers  


Did you face the problem, changing the properties of an object in Run Time?

1 Answers  


write a script to validate the content in the web application. (do it by OR method) and (do it by Descriptive method by creating a description object..

0 Answers  


How to run scripts 1,29,3,5,7,2 scripts using test batch runner in QTP.... Ie...I wanted to run scripts not in an order 1,2,3,4,5...like that How it is possible using test batch runner... I dont want hardcoded script

0 Answers   IBM,


how to write this script using descriptive programming? the script below is the script generated by QTP plz write the script using descriptive programming? plzzzzzzzz do answer thanku Browser("Welcome: Mercury Tours").Page("orkut - login").WebEdit("Email").Set "test123" Browser("Welcome: Mercury Tours").Page("orkut - login").WebEdit ("Passwd").SetSecure "475259b450e3d212bef4a5f5ce9d32ebcbf4" Browser("Welcome: Mercury Tours").Page("orkut - login").WebButton("Sign in").Click Browser("Welcome: Mercury Tours").Page("orkut - home").Link ("Logout").Click Browser("Welcome: Mercury Tours").Page("orkut - login").Sync Browser("Welcome: Mercury Tours").Close

3 Answers  


How u prepare Test result summary in QTp?

4 Answers   CGI,


Categories