Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 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