I'm going to assume this is some sort of *nix environment due to the requirement for it to be in shell.
The date command can do this for you:
If you need to do this via shell (I'll use bourne as it's the only shell you have on all *nix's), you'll just need to do a little lookup:
The date command is tested, the script is not - some debug may be required.
Some editing will be required to make it fit you larger needs of course too but the core should be enough to get you 95% there.
So I have a csv file where the 3rd field is a date string in the format yyyy-mm-dd. I need to change it to mm/dd/yyyy. So each line in the csv file looks like:
StringData,StringData,2009-02-17,12.345,StringData
StringData,StringData,2009-02-16,65.789,StringData
Any idea how I can keep... (5 Replies)
Hello!
I have a textfile that look like this:
"83d1:46:2b";"20091008190000";"Rögle BK - Skellefteå";"Swedish"
"d4c:46:21";"20091008190000";"Södertälje - Brynäs";"Swedish"
"d4b:46:2";"20091008190000";"HV 71 - Färjestad";"Swedish"
"838:46:b";"20091010160000";"Skellefteå - HV 71";"Swedish"... (2 Replies)
I have a CSV file with a date format like this;
11/19/2012 17:37:00,1.372,121.6
11/19/2012 17:38:00,0.743,121.6
Want to change the time stamp to seconds after 1970 so I can get the data in rrdtool. For anyone interested, this is data from a TED5000 unit and is Kwatts and volts.
Needs to... (3 Replies)
Hi,
i have a flat file namely temp.txt with this data below
ID|name|contact_date
101|Kay|2013-12-26
102|let|2013-12-26
I need to modify the date data in the flat file into MM/DD/YYYY HH24:MI:SS format
let me know the code for this.
Thank you! (5 Replies)
I have a csv file formatted like this:
2014-08-21 18:06:26,A,B,12345,123,C,1232,26/08/14 18:07and I'm trying to change it to MM/DD/YYYY HH:MM for both occurances.
I have got this:
awk -F, 'NR <=1 {print;next}{"date +%d/%m/%Y\" \"%H:%m -d\""$1 "\""| getline dte;$1=dte}1' OFS="," test.csvThis... (6 Replies)
Hi All,
I'm new to forum good to hear all.
I stuck in converting date format in csv file using unix
csv file contains as below
,750,0000000000000000GCJR, ,06/22/2016 14:48:44
I want to convert into as below
,750,0000000000000000GCJR, ,06/22/2016 02:48:44 PM
Please reply asap..... (22 Replies)
Hi all,
I have a file as below,
i would like the change the format of the time from "11/7/2019 20:12" to "2019-07-11 20:12:00" in the last coloumn.
any awk solution on this.
Input:
2,0,695016,1961612,497212,5800804,0,0,161,33,7605,12226,23,10,66,0,0,34,11/7/2019 20:10... (4 Replies)
Discussion started by: Raghuram717
4 Replies
LEARN ABOUT DEBIAN
parsedate
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.10, dated 1993/01/29.
SEE ALSO date(1), ctime(3), libinn(3), time(2).
PARSEDATE(3)