Change the date format from mmddyyyy to yyyymmdd


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change the date format from mmddyyyy to yyyymmdd
# 1  
Old 04-26-2010
Change the date format from mmddyyyy to yyyymmdd

How do I change the date format from mmddyyyy to yyyymmdd in PERL.

Can any one help me please.
# 2  
Old 04-26-2010
Code:
perl -wle '(undef,undef,undef,$mday,$mon,$year) = localtime(time);print $year+1900,$mon+1,$mday;'

SmilieSmilieSmilie
# 3  
Old 04-26-2010
Code:
$ perl -le '$x="04262010"; $x =~ /(\d{2})(\d{2})(\d{4})/; print $3,$1,$2'
20100426

# 4  
Old 04-26-2010
Thanks..

Thanks for the reply.... But how do I use the same in the script..?

when I use the same its not working.

Code:
$readabledate =~ '/(\d{2})(\d{2})(\d{4})/; print $3,$1,$2';

Please help

Last edited by Scott; 04-26-2010 at 10:57 AM.. Reason: Fixed code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Date format change from mm/dd/yyyy to yyyymmdd in comma seperate line in perl

Hi All, I have line ,A,FDRM0002,12/21/2017,,0.961751583,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, it contains date in mm/dd/yyyy format i want to change this to yyyymmdd format using perl. Use code tags, thanks. (8 Replies)
Discussion started by: vishal0746
8 Replies

2. Shell Programming and Scripting

Date format to be changed from DDMMYYYY to YYYYMMDD

My requirement is:- there will be files at a location each day with the date format DDMMYYYY. Novawise_Activity_Call_Notes_04022013.txt Novawise_Activity_Inbound_04022013.txt Novawise_Activity_Inbound_05022013.txt Novawise_Activity_Call_Notes_05022013.txt... (8 Replies)
Discussion started by: djrulz123
8 Replies

3. Shell Programming and Scripting

Validating date in yyyymmdd format using PERL

Hi all, i had a code where in user will enter a date in yyyymmdd format.. i didnt use any validation for the date and now the problem is if a user enters date instead of month after year it is proceeding with the code.. like if the date is 20120426 and if the user enters 20122604 it... (4 Replies)
Discussion started by: smarty86
4 Replies

4. Shell Programming and Scripting

Date after 5 days from current date in YYYYMMDD format

Hello Experts, How do i get date after 5 days from current date in YYYYMMDD format? How do you compare date in YYYYMMDD format? Thanks (8 Replies)
Discussion started by: needyourhelp10
8 Replies

5. Solaris

Date after 5 dates in YYYYMMDD format

Hi Experts, How to get date 5 days after current date in YYYYMMDD format? How do we compare date in YYYYMMDD format? Thanks (1 Reply)
Discussion started by: needyourhelp10
1 Replies

6. UNIX for Dummies Questions & Answers

perl yesterday's date in mmddyyyy format

Hi, Below command is producing yesaterday's date in mmddyy format - perl -e '@T=localtime(time-86400);printf("%02d%02d%02d",$T+1,$T,($T+1900)%100)' But i want the date in mmddyyyy format; plz help. Thankx, Rahul Bahulekar. ---------- Post updated at 05:13 AM ---------- Previous... (1 Reply)
Discussion started by: rahulbahulekar
1 Replies

7. Shell Programming and Scripting

convert date format YYYYMMDD to MM/DD/YYYY

In my shell script i have a variable which stores date in the format of YYYYMMDD. Is there any way to format this value to MM/DD/YYYY. Thanks. (8 Replies)
Discussion started by: nasirgondal
8 Replies

8. UNIX for Dummies Questions & Answers

Format date from MM/DD/YYYY to YYYYMMDD

I have a file with some date columns in MM/DD/YYYY format: SMPBR|DUP-DO NOT USE|NEW YORK||16105|BA5270715|6/6/2007 |MWERNER|109||||JOHN||SMITH|MD|72211118||||||74559|21 WILMINGTON RD||D|11/6/2003|SL# MD CONTACT-LIZ RICHARDS|||0|Y|N||1411458| And I want to convert the date format to: ... (5 Replies)
Discussion started by: ChicagoBlues
5 Replies

9. HP-UX

How can i get the yesterday's date in YYYYMMDD format

How can i get the yesterday's date in YYYYMMDD format??? (4 Replies)
Discussion started by: prasadsr
4 Replies

10. UNIX for Dummies Questions & Answers

get yesterday date in yyyymmdd format

I would like to know how I could get a yesterday date in yyyymmdd e.g. today is 20011109, and I would like to get 20011108. Thank you!:confused: (2 Replies)
Discussion started by: hk_newbie
2 Replies
Login or Register to Ask a Question