Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Compare a date (mm/dd/yyyy) with awk Post 303035662 by vgersh99 on Thursday 30th of May 2019 12:11:52 PM
Old 05-30-2019
how about for starters...
awk -F, -v sd='01/02/2015' -f old.awk myFile where old.awk is:
Code:
function conv(d,  t) {
   split(d, t, "/")
   return (sprintf("%d%.02d%.02d", t[3], t[1], t[2]))
}
BEGIN {
  tab=sprintf("\t")
  somed=conv(trim(sd))
}

function trim(str)
{
    sub("^([ ]*|" tab "*)", "", str);
    sub("([ ]*|" tab "*)" "$", "", str);
    return str;
}

trim($3) == "yes" && conv(trim($7))>=somed

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Date Vadidation in YYYY-MM-DD

Date Vadidation in YYYY-MM-DD Hi , Please, Help me in validating given date that is passed in arg as YYYY-MM-DD. It should cover check 1 <= DD <= 31 and 1 <= MM <= 12 for each mm check 1 <=DD<= {28,30,31} (depending) for someYYYY and MM== 02 check 1 <= dd <= 29 I the... (1 Reply)
Discussion started by: itsmehihihi
1 Replies

2. Shell Programming and Scripting

Change Date from dd-mmm-yyyy to mm/dd/yyyy

I want to change a date from format dd-mmm-yyyy to mm/dd/yyyy. Is there a way to do this with sed or do you have to write a case statement to convert JAN to 01? Thanks (9 Replies)
Discussion started by: stringzz
9 Replies

3. Shell Programming and Scripting

converting the date field from dd/mm/yyyy to yyyy/mm/dd

How to convert the date field from dd/mm/yyyy to yyyy/mm/dd in unix my script will generate text file which have two fields one is date and another is name of the server for example this is sample date which I have to sort based on older to newer date the problem is when I found out sort will... (4 Replies)
Discussion started by: pareshan
4 Replies

4. Shell Programming and Scripting

change date format from yyyy/mm/dd to dd/mm/yyyy

(Attention: Green PHP newbie !) I have an online inquiry form, delivering a date in the form yyyy/mm/dd to my feedback form. If the content passes several checks, the form sends an e-mail to me. All works fine. I just would like to receive the date in the form dd/mm/yyyy. I tried with some code,... (6 Replies)
Discussion started by: keyboarder
6 Replies

5. Shell Programming and Scripting

Converting date DD MM YYYY to DD MON YYYY

Hello, I am writing a script that parses different logs and produces one. In the source files, the date is in DD MM YYYY HH24:MI:SS format. In the output, it should be in DD MON YYY HH24:MI:SS (ie 25 Jan 2010 16:10:10) To extract the dates, I am using shell substrings, i.e.: read line ... (4 Replies)
Discussion started by: Adamm
4 Replies

6. Shell Programming and Scripting

awk compare column with date format

I have this code to compare columns 1 and 10 between file1 and file 2 and give me all records that match column 1 but dont match column 10 However column 10 is date format mm/dd/yy and awk cant read it and compare ...i tried awk < file1 -F~ '{print $10}' and it gave blank screen Is... (1 Reply)
Discussion started by: sigh2010
1 Replies

7. Shell Programming and Scripting

Need date in the format [mm dd yyyy hh AM/PM]

could you please help be on the below code .. Requirement is when i pass the parameter(for below 2) i should get current time -2 hours in the format :wall:.. cur_dt=`$ICEBIN/sqsh -S$DSQUERY -U $BATCHID -P $PASSWD -h -C"select getdate()" | sed '2d'` pr_dt="`$ICEBIN/sqsh -S$DSQUERY -U $BATCHID... (2 Replies)
Discussion started by: karthicss
2 Replies

8. Shell Programming and Scripting

Date conversion help from dd/mm/yyyy to dd/Mon/yyyy i.e. 28/10/2012 to 28/Oct/2012

Hi I have a problem with Date format in my code. 1st I am trying to convert today's date to yesterday's using YESTERDAY3=`perl -e '@y=localtime(time()-86400); printf "%04d/%02d/%02d",$y+1900,$y+1,$y;$y;'` And once it is done I am trying to using the yesterday date in a grep command to... (3 Replies)
Discussion started by: nithinankam
3 Replies

9. UNIX for Dummies Questions & Answers

Epoch date to YYYY/MM/DD or MM/DD/YYYY

I've seen a lot of posts on this and have tried the following: echo 1257000000| perl -e '($d,$m,$y)=(localtime(time-86400));$m+=1;$y+=1900;printf "$y/$m/$d\n";' But I am unable to convert a past Epoch date into a format such as YYYY/MM/DD or MM/DD/YYYY. I am using bash and don't know... (4 Replies)
Discussion started by: newbie2010
4 Replies

10. Shell Programming and Scripting

Date format YYYY/MM/DD to DD/MM/YYYY

I am getting output of YYYY-MM-DD and want to change this to DD/MM/YYYY. When am running the query in 'Todd' to_date(column_name,'DD/MM/YYYY') am getting the required o/p of DD/MM/YYYY, But when am executing the same query(Netezza) in linux server(bash) am getting the output of YYYY-MM-DD file... (3 Replies)
Discussion started by: Roozo
3 Replies
insnstr(3XCURSES)					  X/Open Curses Library Functions					 insnstr(3XCURSES)

NAME
insnstr, insstr, mvinsnstr, mvinsstr, mvwinsnstr, mvwinsstr, winsnstr, winsstr - insert a multibyte character string SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int insnstr(const char *str, int n); int insstr(const char *str); int mvinsnstr(int y, int x, const char *str, int n); int mvinsstr(int y, int x, const char *str); int mvwinsnstr(WINDOW *win, int y, int x, const char *str, int n); int mvwinsstr(WINDOW *win, int y, int x, const char *str); int winsnstr(WINDOW *win, const char *str, int n); int winsstr(WINDOW *win, const char *str); PARAMETERS
str Is a pointer to the string to be inserted. n Is the number of characters not to exceed when inserting str. If n is less than 1, the entire string is inserted. y Is the y (row) coordinate of the starting position of the string. x Is the x (column) coordinate of the starting position of the string. win Is a pointer to the window in which the string is to be inserted. DESCRIPTION
The insstr() function inserts str at the current cursor position of the stdscr window. The winsstr() function performs the identical action, but in window win. The mvinsstr() and mvwinsstr() functions insert the character string at the starting position indicated by the x (column) and y (row) parameters (the former to the stdscr window; the latter to window win). The insnstr(), winsnstr(), mvinsnstr(), and mvwinsnstr() functions insert n characters to the window or as many as will fit on the line. If n is less than 1, the entire string is inserted or as much of it as fits on the line. The former two functions place the string at the current cursor position; the latter two commands use the position specified by the x and y parameters. All characters to the right of inserted characters are moved to the right. Characters that don't fit on the current line are discarded. The cursor is left at the point of insertion. If a character in str is a newline, carriage return, backspace, or tab, the cursor is moved appropriately. The cursor is moved to the next tab stop for each tab character (by default, tabs are eight characters apart). If the character is a control character other than those previously mentioned, the character is inserted using ^x notation, where x is a printable character. clrtoeol(3XCURSES) is automati- cally done before a newline. RETURN VALUES
On success, these functions return OK. Otherwise, they return ERR. ERRORS
None. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
addchstr(3XCURSES), addstr(3XCURSES), clrtoeol(3XCURSES), ins_nwstr(3XCURSES), insch(3XCURSES), libcurses(3XCURSES), attributes(5), stan- dards(5) SunOS 5.11 5 Jun 2002 insnstr(3XCURSES)
All times are GMT -4. The time now is 07:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy