I have two values created from strftime as below
TIMEFORMAT=\"%Y-%m-%d %H:%M:%S\"
time1 = time.strftime(TIMEFORMAT)
time2 = time.strftime(TIMEFORMAT)
I use GNU-Awk (gawk) in UNXUTILS on a Win-7 PC. This answer to the strftime(.) question raises a small puzzle of its own. I have a similar problem. In financial market data I have a date-time string ($25) given as "03-APR-2006 09:55:25" (so time = substr($25, 13, 8)) and my objective is to count records (especially order cancellation records) that come in after 14:00:00 (2 pm).
In my code I have a line which reads
{ if ($3==3) {
{ ++CK_NR}
{ ++CO_NR[$4, substr($25, 1, 11)] }
{ if (strftime(substr($25, 13, 8)) > ("14:00:00"))\
{
{ ++CK_LATE_NR }
{ ++CO_LATE_NR[$4, substr($25, 1, 11)] }
}
}
}
}
Just realized that the inequality I used -- if (strftime(substr($25, 13, 8)) > ("14:00:00")) -- has only a string in the RHS, and I didn't make this string the argument of another strftime(.). What's puzzling is that it did NOT give me an error.
Am concerned that while it has not generated any errors, and the code has run, perhaps it is giving me something other than what I intended with the code. In a Command Prompt Window, doing
\>gawk "{ print (strftime(\"09:55:25\") > (\"14:00:00\")) }"
does yield "0" and
\>gawk "{ print (strftime(\"09:55:25\") < (\"14:00:00\")) }"
does yield "1". The GNU Awk Manual (http://www.gnu.org/software/gawk/manual/gawk.html#Time-Functions) yields little information on what is required for a meaningful comparison. Just now tried the above deleting the "strftime" even from the LHS, as under
\>gawk "{ print ((\"09:55:25\") > (\"14:00:00\")) }"
and
\>gawk "{ print ((\"09:55:25\") > (\"14:00:00\")) }"
and got the same results. So while I offer this as a candidate "answer," I want to be sure that I am getting the correct True/False result because GAWK is comparing time, and not for some other internal rule it uses in making string comparisons (causing the limited test to be only a coincidence). Can someone resolve this puzzle? Thanks. Best,
Murgie