Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular expression for date fields

Status
Not open for further replies.

theniteowl

Programmer
May 24, 2005
1,975
0
0
US
First let me say, I am not using ASP for this. The app I use has it's own proprietary scripting language that just added RegExp support and it is not well documented yet.
So I have to use basic expressions to do what I could otherwise do with other ASP functions.

I have a date formatted yy/dd/mm
Most simply I need to format that date as yyyy/dd/mm
Is there an easy expression to reformat the year to four digits?
To add a little complexity, can the expression determine if the date is already 4 digits before changing it?

And finally, could the expression also change the slashes to hyphens?

I ask these individually because I am not sure how well supported the expressions are and I would like to try out the individual pieces as well as all together to see what does and does not work and seeing the pieces seperate and together will help me better understand them.

Thanks for any help.
There is no forum for the app I use so I posted here since RegExp is supported in ASP and I hope that little or no differences will exist between what ASP uses and this app supports.


At my age I still learn something new every day, but I forget two others.
 
Never mind.
I can do basic tests to see if the year is 2 or 4 digits but the application is not capable of doing the more advanced replace functions. I can search with an expression and replace matches but only with fixed text. So I cannot do something like reformat the date by moving the year from the end to the beginning or insert characters in front of the 2 digit year to make it four digits.

At my age I still learn something new every day, but I forget two others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top