Subtract millisecond Timestamps with awk

Hello, am not able to subtract timestamps in milliseconds.

I extract the timestamp as a string, and then try to subtract the two, but since it is a string, system just outputs 0


awk -F"," 'substr($1,0,13) - substr($2,0,013)' File


where $1 and $2 are the timestamps in the format HH:MM:SS.000

I have seen the usage of date -d command, but not sure how to pass it to the command line as arguments to awk.

Note the File contains 1000 rows

Try converting "HH:MM:SS" to seconds. Will the timestamps cross midnight? Month end? Year end?

How should I do that? With the date command? The timestamps wont cross midnight, it begins from midnight until 23:59:59.xxx

Now - how many minutes does an hour have? And how many seconds a minute? Do you know about awk 's split command?

BTW, your attempt will print nothing if the hours are the same, and the input line if different.

You can calculate seconds from HH:MM:SS via seconds+(minutes*60)+(hours*60*60)