I have historical data that I pulled using SQL which I I'm looping through for the accumulative time down for the multiple chutes on our system item[1]. Which I don't think I have a problem with. I have both the current alarm time and the historical alarm times. I just wanted to combine the two.
For example:
nd_time[count2] is the current alarm duration. It is a string and contains "00:10:50"
item[1] is the historical time it's unicode and contains "01:09:54"
If I just try adding them together it just adds the strings to "00:10:5001:09:54"
I can convert them both to datetime.datetime like I've done below but then I get a type error when using datetime.combine:
TypeError("time argument must be a time instance")
I want to combine "00:10:50" and "01:09:54" and get "01:20:44"
All of that aside, I strongly recommend not using the python Datetime module, for anything. Instead use java and or Ignition's own date functions.
Of course it does. To the interpreter these are just strings, and so the result you get is the concatenation of them.
I think you have a fundamental misunderstanding of what datetime.combine() actually does. It takes a date and a time and combines them into a single datetime object representing a date and time. In this case you have two times, and (I think) you want to add them together.
Okay, assuming you're stuck for some reason with strings in the database instead of datetime objects, how do you solve your issue? First convert the string time values into something that we can work with as a representation of a date.
This code will convert a string with your format into a date object.