Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

to convert datetime into date string from 2019-05-02 12:00:00 to 2019-05-02

I am trying to run a query inside a package in sql transformation. tryo to convert the datetime to string where i have the value 2019-05-02 12:00:00 AM to 2019-05-02

*
FROM <MyTable>  where datekey ='" + (DT_STR,20,1252)(@[User::NextStartTime]) + "'

I tried this but it gives an output as datekey = '12:00:00 AM' but i am looking for '2019-05-02'

like image 759
Tamil Babu Avatar asked Nov 06 '22 17:11

Tamil Babu


1 Answers

You can simply use the following expression:

LEFT((DT_WSTR,50)@[User::NextStartTime],10)

Output:

2019-05-10

Based on the Cast (SSIS Expression) official documentation:

When a string is cast to a DT_DATE, or vice versa, the locale of the transformation is used. However, the date is in the ISO format of YYYY-MM-DD, regardless of whether the locale preference uses the ISO format.

like image 156
Hadi Avatar answered Nov 12 '22 17:11

Hadi