Search code examples
datetimessismilliseconds

SSIS how to set milliseconds to be zero?


I need to set fractional seconds of timestamp value to be zero.

E.g. Set "2012-11-10 14:57:43.147" to be "2012-11-10 14:57:43.000"

How could I do this in SSIS expression? Thx!


Solution

  • Try this as a proof of concept if you'd even want to set seconds to 00:

    (DT_DBTIMESTAMP2,7)(SUBSTRING((DT_WSTR,27)(DT_DBTIMESTAMP2,7)"2012-11-10 14:57:43.147",1,16)+":00")
    

    Similarly, for the eradication of milliseconds, take the first 19 characters:

    (DT_DBTIMESTAMP2,7)SUBSTRING((DT_WSTR,27)(DT_DBTIMESTAMP2,7)"2012-11-10 14:57:43.147",1,19)