Solved

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

Posted on 2011-03-03
4
644 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:sjklein42
ID: 35034217
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
ID: 35034291
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
ID: 35034309
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
ID: 35034843
thank you so much!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…

724 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