You need to parse dates to seconds and compare them. You have to use mktime()
function, that accepts a string with each part of a date, so you will have to split()
it first. This program is weird because it has much repeated code, but it seems to work, and I hope you get the idea:
awk '
BEGIN {
date1 = "04/02/2014"
split(date1, arr, "/")
seconds1 = mktime(arr[3] " " arr[2] " " arr[1] " 0 0 0")
date2 = "06/02/2014"
split(date2, arr, "/")
seconds2 = mktime(arr[3] " " arr[2] " " arr[1] " 0 0 0")
}
{
split($NF, arr, "/")
s = mktime(arr[3] " " arr[2] " " arr[1] " 0 0 0")
if (s >= seconds1 && s <= seconds2) {
print $0
}
}
' infile
With your second example data, it yields:
TMYO140045M:=TMYO140045M P33BJq MARS 04/02/2014
TMYO140046M:=TMYO140046M P33BJq RENN 04/02/2014
TMYO140047M:=TMYO140047M P33BJl AKHT 05/02/2014
TMYO140048M:=TMYO140048M P3l MACL 05/02/2014
TMYO140049M:=TMYO140049M P3q HAYE 06/02/2014
TMYO140050M:=TMYO140050M P3q ROCH 06/02/2014
TMYO140051M:=TMYO140051M P3q FORR 06/02/2014