Sponsored Content
Top Forums Shell Programming and Scripting Convert string into date format Post 302873151 by RavinderSingh13 on Monday 11th of November 2013 08:50:56 AM
Old 11-11-2013
Hello,

Here is one more approach. Let us say file name which is having input is change_data_format.


Code:
 awk -F"/" '{
 split("Jan,Feb,March,April,May,june,july,Aug,Sept,Oct,Nov,Dec",month,",");
 print $2"-" month[$1] "-" $3}' change_data_format

Output will be as follows.

Code:
03-Dec-2013 11:02 AM




Thanks,
R. Singh
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

convert mmddyy date format to ccyyddd format??

hi, for reading a cobol indexed file i need to convert "mmddyy" date format to "ccyyddd" format. i checked the datecalc and other scripts but couldnt modify them to cater to my need:(... The datecalc gives an output which i believe is the total days till that date, but i want to convert it... (2 Replies)
Discussion started by: Bhups
2 Replies

2. UNIX for Dummies Questions & Answers

Convert date format

Hi All, Need your help in converting a date format in ksh. I'm currently working on SUN os where my script is getting a date from a table. The result returns to ksh in this format: 17-JUL-08 How do i convert this string to a date format like yyyymmdd? I tried #!/bin/ksh d="17-JUL-08"... (5 Replies)
Discussion started by: agathaeleanor
5 Replies

3. Shell Programming and Scripting

convert date format to mysql date format in log file

I have a comma delimited log file which has the date as MM/DD/YY in the 2nd column, and HH:MM:SS in the 3rd column. I need to change the date format to YYYY-MM-DD and merge it with the the time HH:MM:SS. How will I got about this? Sample input 02/27/09,23:52:31 02/27/09,23:52:52... (3 Replies)
Discussion started by: hazno
3 Replies

4. 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

5. Shell Programming and Scripting

convert date format

I've been using this thread: https://www.unix.com/shell-programming-scripting/58675-change-date-dd-mmm-yyyy-mm-dd-yyyy.html and https://www.unix.com/shell-programming-scripting/14655-changing-yyyy-mm-dd-ddmmyy.html and this code: on this format: 05/16/2008 18:30:49 Installation 48985and I'm... (3 Replies)
Discussion started by: dba_frog
3 Replies

6. Shell Programming and Scripting

awk convert date format

Could you tell me how to convert the following dates? If I have m/d/yyyy, I want to have 0m/0d/yyyy. I want my dates to always be 8 digits. In other words, I want a 0 inserted whenever the month or day is a single digit. My issue is first I need to use FS="," to get field $4 for the... (7 Replies)
Discussion started by: wbrunc
7 Replies

7. Shell Programming and Scripting

Convert Date Format

Hello, I want to change the format of date value in variable. e.g. cur_date = '2013/03/13 14:24:50' (yyyy/mm/dd hh24:mi:ss) I want to change this to '13-MAR-2013 14:24:50 Following code coverts the current date to format I am looking for. But I do not know how this can be done for a date... (8 Replies)
Discussion started by: cartrider
8 Replies

8. Shell Programming and Scripting

Convert date format

Hi guys I am looking to convert this kind of entry in a txt file 26/04/2008 to April 2008 Note : this is not using the date command , these are date entries in a file can i do this with sed ? Use code tags, thanks. (5 Replies)
Discussion started by: johnnybananas
5 Replies

9. 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

10. 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
JDMONTHNAME(3)								 1							    JDMONTHNAME(3)

jdmonthname - Returns a month name

SYNOPSIS
string jdmonthname (int $julianday, int $mode) DESCRIPTION
Returns a string containing a month name. $mode tells this function which calendar to convert the Julian Day Count to, and what type of month names are to be returned. Calendar modes +-----+--------------------------------------+---+ |Mode | | | | | | | | | Meaning | | | | | | | | Values | | | | | | +-----+--------------------------------------+---+ | 0 | | | | | | | | | Gregorian - abbreviated | | | | | | | | Jan, Feb, Mar, Apr, May, Jun, Jul, | | | | Aug, Sep, Oct, Nov, Dec | | | | | | | 1 | | | | | | | | | Gregorian | | | | | | | | January, February, March, April, | | | | May, June, July, August, September, | | | | October, November, December | | | | | | | 2 | | | | | | | | | Julian - abbreviated | | | | | | | | Jan, Feb, Mar, Apr, May, Jun, Jul, | | | | Aug, Sep, Oct, Nov, Dec | | | | | | | 3 | | | | | | | | | Julian | | | | | | | | January, February, March, April, | | | | May, June, July, August, September, | | | | October, November, December | | | | | | | 4 | | | | | | | | | Jewish | | | | | | | | Tishri, Heshvan, Kislev, Tevet, She- | | | | vat, AdarI, AdarII, Nisan, Iyyar, | | | | Sivan, Tammuz, Av, Elul | | | | | | | 5 | | | | | | | | | French Republican | | | | | | | | Vendemiaire, Brumaire, Frimaire, | | | | Nivose, Pluviose, Ventose, Germinal, | | | | Floreal, Prairial, Messidor, Thermi- | | | | dor, Fructidor, Extra | | | | | | +-----+--------------------------------------+---+ PARAMETERS
o $jday - The Julian Day to operate on o $calendar - The calendar to take the month name from RETURN VALUES
The month name for the given Julian Day and $calendar. PHP Documentation Group JDMONTHNAME(3)
All times are GMT -4. The time now is 04:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy