Solved

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

Posted on 2011-03-03
4
638 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…

914 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

16 Experts available now in Live!

Get 1:1 Help Now