Hello Statalist community, I am struggeling with converting a string containing date and time information inti SIF/HRF. It seems that the seconds aren't converted corrctly. Maybe I am mistaken and use the wrong commands to perform my transformation or maybe the error lies in the wrong display format. As far as I know, I tried all i cound trying to get the right results but actually I failed.

Please can you help me to get the transformation right?

Original string information:

Code:
. describe treatmenttime

              storage   display    value
variable name   type    format     label      variable label
-----------------------------------------------------------------------------
treatmenttime   str19   %19s                  Treatment Time


. list treatmenttime in 1

     +---------------------+
     |       treatmenttime |
     |---------------------|
  1. | 2018-10-10 17:27:14 |
     +---------------------+
Transformation attempt string --> SIF:

Code:
gen treatmenttime2= Clock(treatmenttime, "YMDhms")

. describe treatmenttime2

              storage   display    value
variable name   type    format     label      variable label
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
treatmenttime2  float   %9.0g   

. list treatmenttime2 in 1

     +----------+
     | treatm~2 |
     |----------|
  1. | 1.85e+12 |
     +----------+


. format treatmenttime2 %tC

. list treatmenttime2 in 1

     +--------------------+
     |     treatmenttime2 |
     |--------------------|
  1. | 10oct2018 17:27:21 |
     +--------------------+
So you see: I started with:

2018-10-10 17:27:14

and got

10oct2018 17:27:21

after the transformation.

Furthermore, the actual difference between starting time and transformed time varies depending on the very content of the string between few seconds and minutes which is even more frustrating.