Your column configuration at DB seems to have the wrong type. It looks like you have configured it as datetime but you’re giving a unicode. When you do system.date.format(datetime,‘HH:mm:ss’) you’re only extracting the time part as string but not the date.
Reconfigure your db column to be Time() or LongBlob() datatype.
Yeah, but that is an expression tag that could be changing (plus he is reading the MemTimeDiff tag not the TimeDiff tag which is confusing me). Would also double check the tag hierarchy here as the relative tagpath [.]../MemTimeDiff indicates the script should be on a tag in a folder one level down from the MemTimeDiff tag (if I remember my .'s correctly).
@antonio.sanchez I see you mentioned earlier that you are getting a non-zero value for your timeDiff variable, but I didn’t actually see the result of the print, just a screenshot of your tags. Can you post the actual results from your print statements here?