SSIS - Remove time part from a date time value

Problem:

How to remove from DateTime variable hours, minutes, seconds and other parts in SSIS
If I have DateTime like 21 jul 2019 8:30:05, and I want have it as 21 jul 2019 00:00:00 and still as DateTime not string

Solution:

You can achieve that using a derived column:
(DT_DBTIMESTAMP)(DT_DBDATE)@[User::DateTimeVariable]
Casting to DT_DBDATE will remove the time part, then recasting to DT_DBTIMESTAMP will re-add a time part but with 12:00 AM value = 00:00:00
Example:
enter image description here
Original post: https://stackoverflow.com/questions/57221410/how-to-remove-from-datetime-variable-hours-minutes-seconds-and-other-parts-in/57221736#57221736

Comments

Popular posts from this blog

SSIS - Script Task error: Exception has been thrown by the target of an invocation.

Don’t install Hadoop on Windows!

SSIS - script component DateTime Formats Implicit Conversion