Show the string in date format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Show the string in date format
# 1  
Old 02-06-2015
Show the string in date format

Hello guys.
how can print the:
Code:
20140206

like
Code:
Fri, Feb  6, 2015

Thank you.
# 2  
Old 02-06-2015
Hello Ymir,

Could you please try following and let me know if this helps.
Code:
 date -d"20140206" +%A", "%B", "%d", "%Y

Output will be as follows.
Code:
Thursday, February, 06, 2014

NOTE: I am using GNU date, it should work in GNU version of date.


Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Old 02-06-2015
Quote:
Originally Posted by RavinderSingh13
Hello Ymir,

Could you please try following and let me know if this helps.
Code:
 date -d"20140206" +%A", "%B", "%d", "%Y

Output will be as follows.
Code:
Thursday, February, 06, 2014

NOTE: I am using GNU date, it should work in GNU version of date.

Thank you. it work in commen shell scripts. but it didn't work in awk END part.
Thanks,
R. Singh
# 4  
Old 02-06-2015
Hello Ymir,

Could you please try following and let me know if this helps.
Code:
echo "20140206" | awk 'END{system("date -d"$0" +%A,%B,%d,%Y")}'

Output will be as follows.
Code:
Thursday,February,06,2014

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 5  
Old 02-06-2015
Try also
Code:
awk 'BEGIN {Y=20150206; print Y | "read X; date +\"%a,%b %d, %Y\" -d $X"}'
Fri,Feb 06, 2015

This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Convert string (YYYYMMDD) format to date in Sun OS

Hi All I need help in converting a string of YYYYMMDD format to date in Sun OS and then find out if the day is a Wednesday or not. The "date -d" option is not working and your help is much appreciated. The date command usage from the operating system we use here is as follows: Thanks, SK (11 Replies)
Discussion started by: SK123
11 Replies

2. Shell Programming and Scripting

Convert string (YYYYMMDD) format to date in Sun OS

Hi All I need help in converting a string of YYYYMMDD format to date in Sun OS and then find out if the day is a Wednesday or not. The "date -d" option is not working and your help is much appreciated. The date command usage from the operating system we use here is as follows: usage: ... (1 Reply)
Discussion started by: SK123
1 Replies

3. Shell Programming and Scripting

Convert string into date format

Hi, I am getting the below string as a input for date. 12/03/2013 11:02 AM I want to change this date as 03-DEC-2013 11:02 AM. Could you please help on this. Thanks Chelladurai (4 Replies)
Discussion started by: ckchelladurai
4 Replies

4. Shell Programming and Scripting

Compare Date with String in date format

Hi, I am new to this forum, searched, but for some reason did not find much help, so a new thread. I am trying to compare date with a string which is in date format , but for some reason, system does not give me the right result. Date is coming in a file and i am comparing the same with... (2 Replies)
Discussion started by: mkstool
2 Replies

5. Shell Programming and Scripting

Date format check and replace string in PERL

I have got few date format patterns like "yyyymmdd", "yy_mm_dd" etc. There can be any combination of such patterns. I have used add_delta_days to find "yyyy", "yy", "mm", "dd" for the current date and saved them to different variables like "$y1", "$y2", "$m1" etc In one line, i want to... (10 Replies)
Discussion started by: irudayaraj
10 Replies

6. Shell Programming and Scripting

How to format string/date in bash?

I have string like "1-JUN-11" and it needs to be converted to "01JUN11" and "1/6/2011":confused::confused::confused: Thanks (2 Replies)
Discussion started by: ford99
2 Replies

7. Shell Programming and Scripting

To convert a date(in string format) to unix timestamp

Hi All, I have a string like below. "Mar 31 2009" . I want to convert this to unix time . Also please let me know how to find the unix time for the above string minus one day. For Eg. if i have string "Mar 31 2009" i want to find the unix time stamp of "Mar 30 2009". Thanks in advance,... (11 Replies)
Discussion started by: girish.raos
11 Replies

8. Shell Programming and Scripting

Which is the STRING format in the date command?

Hi According with the 'date' command documentation My question is, which are the possible values for STRING? I have been looking in the man pages but I didn't find anything? After some googling I have found it can have special values as 'now', 'yesterday' or 'tomorrow'. If it represents... (1 Reply)
Discussion started by: islegmar
1 Replies

9. UNIX for Dummies Questions & Answers

How to format a date string

I have a file tmp.out with contents: 20080812 02:41:07 20080812 05:03:04 20080812 05:46:16 How do I format the contents such as: 2008-08-12 02:41:07 2008-08-12 05:03:04 2008-08-12 05:46:16 Thanks, - CB (2 Replies)
Discussion started by: ChicagoBlues
2 Replies

10. Shell Programming and Scripting

grep to show date/time of file the string was found in.

I've seen several examples of grep showing the filename the string was found in, but what I really need is grep to show the file details in long format (like ls -l would). scenario is: grep mobile_number todays_files This will show me the string I'm after & which files they turn up in, but... (2 Replies)
Discussion started by: woodstock
2 Replies
Login or Register to Ask a Question