01-24-2013
awk - change date format
I have below date format in a CSV file. (dd/mm/yyyy)
Ex Input:
9/8/2013
Need to convert it into below format (yyyymmdd ) and redirect to new file.
Ex Output:
20130809
How do I use awk here to change the format and if leading 0 (zero) is not then add it.
Please help. Thanks.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want to chnage the date format from the file format like below to
WT;T15D;0000007208;;20080401;3;0;0;3;;B;ZZZZZZ;
WT;T25D;0000007208;;20080401;6;0;0;6;;B;ZZZZZZ;
WT;T5D;0000007208;;20080401;123;0;0;123;;B;ZZZZZZ;
to
WT;T15D;0000007208;;04/01/200804;3;0;0;3;;B;ZZZZZZ;... (2 Replies)
Discussion started by: svenkatareddy
2 Replies
2. Shell Programming and Scripting
Hi All,
this is my second post, last post reply was very helpful.
I have a data that has date in DD/MM/YYYY (07/11/2008) format i want to replace the backslash by a dot(.) so that my awk script can read it inside the C shell script that i have written.
i want to change 07/11/2008 to... (3 Replies)
Discussion started by: asirohi
3 Replies
3. Shell Programming and Scripting
Hi I have a date format in a variable as Mon Jan 11 03:35:59 2010. how do i change it to YYYYMMDD format (3 Replies)
Discussion started by: keerthan
3 Replies
4. Shell Programming and Scripting
Hi,
Please can I have some command to get yesterday in YYMMDD format?
This will be used in ksh
Thanks, (2 Replies)
Discussion started by: smalya
2 Replies
5. Shell Programming and Scripting
Hi Guys,
Can someone help me on how to change the date format using sed or any unix command to give my desired output as shown below.
INPUT FILE:
69372,200,20100122T17:56:02,2
53329,500,20100121T11:50:07,2
48865,100,20100114T16:08:16,2
11719,200,20100108T13:32:20,2
DESIRED... (2 Replies)
Discussion started by: pinpe
2 Replies
6. Shell Programming and Scripting
Dear Friends,
Need your help once again,
I have a variable ( e.g. ${i}) whoch has date in MM/DD/YYYY (E.g. 12/31/2011) format.
I want to change it to DD/MM/YYYY (e.g. 31/12/2011) format.
Request you to guide me as we are unable to do the same.
Thanks in advance
Anu. (1 Reply)
Discussion started by: anushree.a
1 Replies
7. Shell Programming and Scripting
Hi all,
I have a file that every line starts with the date and time. The format is like YYYYMMDDHHMM and I woulk like to change it to MM/DD/YY<space>HH:MM.
I tried to figure out a way to do it with sed, but I don't know how I could reorganize the digits of the first format. Does anyone have any... (1 Reply)
Discussion started by: geovas
1 Replies
8. Shell Programming and Scripting
Hi,
I was looking for a script to change the date from one format to other. A search in the forum gave me the below script as a result.
#! /bin/ksh
format=YYYYMMDD
YEAR=${format%????}
DAY=${format#??????}
MON=${format#$YEAR}
MON=${MON%$DAY}
echo $MON/$DAY/$YEAR
I got it... (2 Replies)
Discussion started by: prithvirao17
2 Replies
9. Shell Programming and Scripting
Example:
Input csv file
00245DLS,Sitel Ocala,12/31/2014,18:45,1.00,7.00,0.00,0.00
00245DLS,Sitel Ocala,12/31/2014,19:00,-1.00,-1.00,-1.00,-1.00
00245HB,Charlotte,01/01/2015,00:00,-1.00,-1.00,-1.00,0.00
Output csv file
00245DLS,Sitel Ocala,2014/12/31,18:45,1.00,7.00,0.00,0.00
00245DLS,Sitel... (8 Replies)
Discussion started by: adit
8 Replies
10. UNIX for Beginners Questions & Answers
Hi,
I have a file where I need to change the date format on the nth field from DD-MM-YYYY to YYYY-MM-DD so I can accurately sort the record by dates
From regex - Use sed or awk to fix date format - Stack Overflow, I found an example using nawk.
Test run as below:
$: cat xyz.txt
A ... (2 Replies)
Discussion started by: newbie_01
2 Replies
LEARN ABOUT HPUX
dtsearchvaliddatestring
DtSearchValidDateString(library call) DtSearchValidDateString(library call)
NAME
DtSearchValidDateString -- Validate and convert a user date string
SYNOPSIS
#include <Dt/Search.h>
DtSrObjdate DtSearchValidDateString(
char *date_string);
DESCRIPTION
DtSearchValidDateString validates a DtSearch date string, as might have been entered by a user in a free form text field, and converts it
into a valid DtSrObjdate.
Since an invalid date string format returns a distinctive DtSrObjdate, this function may also be used as a boolean test for string valid-
ity.
ARGUMENTS
date_string
Specifies the date string to be validated and converted.
The format for a valid date string is "[yyyy [mm [dd]]", one, two, or three ASCII numeric tokens separated by one or more nonnu-
meric chars (whitespace, slashes, etc). The integer yyyy represents a Gregorian calendar year number in the range 1990 to 5995
inclusive. If yyyy is less than 1900, 1900 is added to it. The integer mm is a Gregorian calendar month number in the range 1 to
12 inclusive. The integer dd is a Gregorian calendar day number in the range 1 to 31 inclusive.
If only two tokens are in the string, they are presumed to be yyyy and mm, and dd is presumed to be to 1.
If only one token is in the string, it is presumed to be yyyy, and both mm and dd are presumed to be 1.
RETURN VALUE
DtSearchValidDateString returns zero (a valid DtSrObjdate) if date_string is NULL or empty.
It returns a correctly formatted DtSrObjdate on successful parse and conversion.
It returns -1 and a message on the MessageList if date_string is invalid.
SEE ALSO
DtSrAPI(3), DtSearchQuery(3), dtsrfzkfiles(4), DtSearch(5)
DtSearchValidDateString(library call)