Norman Manzo Nora
asked on
How to convert DATE/TIME String values from GMT to GMT+8, and then Calculate the difference in seconds using BASH or PERL script
Hi experts,
Need help on how to convert a string of values in both 2nd and 3rd fields that are actually Date and Time in GMT and then calculate the difference in seconds.
Preferably using the following scripting methods: BASH or PERL
Sample source file in CSV: inputfile.csv
========================== ========== ========== ========== ========== ========== ========== =========
Required Output File: Start and End Date/Time in GMT+8, plus the Date/Time difference or Duration (in seconds) inserted as a new column (4th field)
Output CSV File: outputfile.csv
Need help on how to convert a string of values in both 2nd and 3rd fields that are actually Date and Time in GMT and then calculate the difference in seconds.
Preferably using the following scripting methods: BASH or PERL
Sample source file in CSV: inputfile.csv
Label,StartDateTime,EndDateTime,status
info01,20171231155000,20171231161000,complete
info02,20180101023025,20180101024045,complete
info03,20180430222210,20180430223002,complete
info04,20180612113050,20180612113502,complete
==========================
Required Output File: Start and End Date/Time in GMT+8, plus the Date/Time difference or Duration (in seconds) inserted as a new column (4th field)
Output CSV File: outputfile.csv
Label,StartDateTime,EndDateTime,Duration(Seconds),status
info01,20171231235000,20180101001000,1200,complete
info02,20180101103025,20180101104045,620,complete
info03,20180501062210,20180501063002,472,complete
info04,20180612193050,20180612193502,252,complete
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Basically, the script works nicely. Just encountered what seemed to be errors, but nevertheless, the desired output was achieved.
All of the errors except possibly the very first one appear to be coming from within DateTime. I do not get those errors. Which version of Perl and of DateTime are you using?
ASKER
Although the output is ok, not sure why Perl is returning some message that seems to be errors. I can choose to ignore this, but just wondering if you have an idea how to clear this?
Once again, thanks for the help :-)
Open in new window