revjax85
Technical User
- Jun 12, 2009
- 1
Hello,
I have a file that contains the following:
034023 052030
051811 061150
061711 091050
071811 111150
031811 151150
091811 123412
060021 180042
123500 142832
I need to convert these times into seconds, subtract field 2 from field 1, and then convert it back to hh:mm:ss.
This is what I have so far any help would be greatly appreciated:
BEGIN {print "Time 1""\t""\t""Time 2""\t""\t""Time 3"}
{
s1=substr(s,1,2)
s2=substr(s,3,2)
s3=substr(s,5,2)
s=sprintf("%s:%s:%s",s1,s2,s3)
}
{print $0 s1*3600,s2*60,s3 }
END{}
I have a file that contains the following:
034023 052030
051811 061150
061711 091050
071811 111150
031811 151150
091811 123412
060021 180042
123500 142832
I need to convert these times into seconds, subtract field 2 from field 1, and then convert it back to hh:mm:ss.
This is what I have so far any help would be greatly appreciated:
BEGIN {print "Time 1""\t""\t""Time 2""\t""\t""Time 3"}
{
s1=substr(s,1,2)
s2=substr(s,3,2)
s3=substr(s,5,2)
s=sprintf("%s:%s:%s",s1,s2,s3)
}
{print $0 s1*3600,s2*60,s3 }
END{}