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
UCWORDS(3)								 1								UCWORDS(3)

ucwords - Uppercase the first character of each word in a string

SYNOPSIS
string ucwords (string $str) DESCRIPTION
Returns a string with the first character of each word in $str capitalized, if that character is alphabetic. The definition of a word is any string of characters that is immediately after a whitespace (These are: space, form-feed, newline, car- riage return, horizontal tab, and vertical tab). PARAMETERS
o $str - The input string. RETURN VALUES
Returns the modified string. EXAMPLES
Example #1 ucwords(3) example <?php $foo = 'hello world!'; $foo = ucwords($foo); // Hello World! $bar = 'HELLO WORLD!'; $bar = ucwords($bar); // HELLO WORLD! $bar = ucwords(strtolower($bar)); // Hello World! ?> NOTES
Note This function is binary-safe. SEE ALSO
strtoupper(3), strtolower(3), ucfirst(3), mb_convert_case(3). PHP Documentation Group UCWORDS(3)
All times are GMT -4. The time now is 04:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy