'Convert yyyymmdd string to yyyy-mm-dd date datatype ignoring the hrs,secs etc.... in SSIS

When I tried to convert the yyyymmdd (DT_Wtsr, string, len 8) to DATE datatype (yyyy-mm-hh) using the below expression:

(DB_DATE)(SUBSTRING([Column],1,4) + "-" + SUBSTRING([Column],5,2) + "-" + SUBSTRING([Column],7,2))

The input yyyymmdd is obtained by concatenating the following strings together:

  • year(yyyy string, len 4)
  • month(mm, string, len 2)
  • day(dd, string, len 2)

My output looks like: yyyy-mm-hh 00:00:00:00000000 (Db_date)

How can I carry out the conversion?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source