-1

I have a datetime format that is displayed as the following:

'13-10-2016 11:58:00'

I require it to be shown as :

'2016-10-13 11:58:00'

How can I change the expression below in order to match this?

Expression:

"SELECT _sessions.session_id AS session_id,   _sessions.user_id AS user_id,   _sessions.updated_at FROM public._sessions _sessions" + (@[User::IncrementalOrFullLoad] == "F" ? "" : " WHERE  

Current output:

SELECT _sessions.session_id AS session_id,   _sessions.user_id AS user_id,   _sessions.updated_at FROM public._sessions _sessions WHERE  
_sessions.updated_at  > '13-10-2016 11:58:00'
Shiva
  • 20,575
  • 14
  • 82
  • 112
BruceyBandit
  • 3,978
  • 19
  • 72
  • 144
  • `datetime` doesn't have an inherent format, the way it's shown depends on your local settings. If you want to display a certain format, you'll have to convert it to a `varchar` – HoneyBadger Oct 13 '16 at 16:19

1 Answers1

1

Producing string from a datetime variable as YYYY-MM-DD hh:mm:ss is simple

(DT_STR, 20, 1252)(DT_DBTIMESTAMP)@[User::YourDateTimeVar]  

The first type cast to DBTIMESTAMP is necessary to avoid format ambiguity. Without it, SSIS .Net process would cast datetime variable to string using process or system culture. First casting to DBTIMESTAMP fixes culture and yields desired result.

Ferdipux
  • 5,116
  • 1
  • 19
  • 33