Solved

Change '01/01/1980' date format to to_date('01/01/1980', 'MM/DD/YYYY')

Posted on 2011-03-03
4
637 Views
Last Modified: 2012-05-11
hi,

i have come across this code:

s{(\d{1,2})/(\d{1,2})/(\d{1,4})}{$1-$2-$3}g;

the code is written in perl. it will change date format from  01/01/1980 to 01-01-1980.
I would like to amend it so that is will look for this date format '01/01/1980' (with single quote) and change in to this "to_date('01/01/1980', 'MM/DD/YYYY')" (exclude the double quote)

thanks in advanced.
0
Comment
Question by:gagajanice
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:sjklein42
Comment Utility
This should do it:

s{(\d{1,2})/(\d{1,2})/(\d{1,4})}{to_date\('$1/$2/$3\'\, \'MM/DD/YYYY\'\)}g;

Open in new window

0
 

Author Comment

by:gagajanice
Comment Utility
hi sjklein42,

thanks for the reply.
but the result is not what i desire: 'to_date('12/06/2010', 'MM/DD/YYYY')'

i would like to get rid of the single quote '...'.
how to include single quote as part of the date format at the first place.

 '01/01/1980' (with single quote) to  "to_date('01/01/1980', 'MM/DD/YYYY')" (exclude the double quote)



0
 
LVL 16

Accepted Solution

by:
sjklein42 earned 500 total points
Comment Utility
s{\'(\d{1,2})/(\d{1,2})/(\d{1,4})\'}{to_date\('$1/$2/$3\'\, \'MM/DD/YYYY\'\)}g

Open in new window

0
 

Author Closing Comment

by:gagajanice
Comment Utility
thank you so much!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now