awk convert date format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk convert date format
# 8  
Old 04-18-2013
Code:
$ sed -r -e 's_,(.)/_,0\1/_' -e 's_/(.)/_/0\1/_' data
,,,12/06/2012,Harry H,Add,Add,Sys_RTH,111.222.333.777
,,,02/06/2012,Carry H,Add,Add,Sys_RTH,111.222.333.777

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed/awk command to convert number occurances into date format and club a set of lines

Hi, I have been stuck in this requirement where my file contains the below format. 20150812170500846959990854-25383-8.0.0 "ABC Report" hp96880 "4952" 20150812170501846959990854-25383-8.0.0 End of run 20150812060132846959990854-20495-8.0.0 "XYZ Report" vg76452 "1006962188"... (6 Replies)
Discussion started by: Chinmaya Kabi
6 Replies

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

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

4. Shell Programming and Scripting

Convert any date format into yyyy/mm/dd

How can I convert any user inputted date into yyyy/mm/dd ? For example user can input date one of the following 20120121 , 2012-01-21 ,01/21/2012,01/21/2012 etc But I need to convert any of the date entered by user into yyyy/mm/dd (2012/01/2012). Any suggestion. Thanks in advance this is... (1 Reply)
Discussion started by: ZeroHedge
1 Replies

5. Shell Programming and Scripting

Using awk or nawk to convert epoch time to date format

Looking for some help and usually when I do a search this site comes up. Hopefully someone can give me a little direction as to how to use one of these two commands to achieve what I'm trying to do. What am I trying to do? I need to take the time value in epoch format returned from the... (5 Replies)
Discussion started by: minigts
5 Replies

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

7. Shell Programming and Scripting

Convert date to Unix format

Dear Expert How to convert date in format of YYYY-MM-DD HH:MM:SS to unix format using a script or command if avaliable Example "2011-05-15 18:00:00" is converted to 1330970400 I tried to use option d in date command but no use, Im using solaris 10 Thanks a lot (12 Replies)
Discussion started by: yahyaaa
12 Replies

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

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

10. 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
Login or Register to Ask a Question
PARSEDATE(3)						     Library Functions Manual						      PARSEDATE(3)

NAME
parsedate - convert time and date string to number SYNOPSIS
#include <sys/types.h> typedef struct _TIMEINFO { time_t time; long usec; long tzone; } TIMEINFO; time_t parsedate(text, now) char *text; TIMEINFO *now; DESCRIPTION
Parsedate converts many common time specifications into the number of seconds since the epoch -- i.e., a time_t; see time(2). Parsedate returns the time, or -1 on error. Text is a character string containing the time and date. Now is a pointer to the time that should be used for calculating relative dates. If now is NULL, then GetTimeInfo in libinn(3) is used to obtain the current time and time- zone. The character string consists of zero or more specifications of the following form: time A time of day, which is of the form hh[:mm[:ss]] [meridian] [zone] or hhmm [meridian] [zone]. If no meridian is specified, hh is interpreted on a 24-hour clock. date A specific month and day with optional year. The acceptable formats are mm/dd[/yy], yyyy/mm/dd, monthname dd[, yy], dd monthname [yy], and day, dd monthname yy. The default year is the current year. If the year is less then 100, then 1900 is added to it; if it is less then 21, then 2000 is added to it. relative time A specification relative to the current time. The format is number unit; acceptable units are year, month, week, day, hour, minute (or min), and second (or sec). The unit can be specified as a singular or plural, as in 3 weeks. The actual date is calculated according to the following steps. First, any absolute date and/or time is processed and converted. Using that time as the base, day-of-week specifications are added. Next, relative specifications are used. If a date or day is specified, and no absolute or relative time is given, midnight is used. Finally, a correction is applied so that the correct hour of the day is produced after allowing for daylight savings time differences. Parsedate ignores case when parsing all words; unknown words are taken to be unknown timezones, which are treated as GMT. The names of the months and days of the week can be abbreviated to their first three letters, with optional trailing period. Periods are ignored in any timezone or meridian values. BUGS
Parsedate does not accept all desirable and unambiguous constructions. Semantically incorrect dates such as ``February 31'' are accepted. Daylight savings time is always taken as a one-hour change which is wrong for some places. The daylight savings time correction can get confused if parsing a time within an hour of when the reckoning changes, or if given a partial date. HISTORY
Originally written by Steven M. Bellovin <smb@research.att.com> while at the University of North Carolina at Chapel Hill and distributed under the name getdate. A major overhaul was done by Rich $alz <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990. It was further revised (primarily to remove obsolete constructs and timezone names) a year later by Rich (now <rsalz@osf.org>) for Inter- NetNews, and the name was changed. This is revision 1.1.1.1, dated 1997/08/04. SEE ALSO
date(1), ctime(3), libinn(3), time(2). PARSEDATE(3)