home
SSIS Expressions
Author Nigel Rivett
Date handling
Note: I have tried to mirror the methods used in T-SQl in these expressions
Current datetime
getdate()
getutcdate()
Datatype conversion
(DT_DATE) "1900-01-01" String to date
(DT_DATE) "1900-01-01 12:01:01" String to date
(DT_STR,1,1252) 20 Integer to String
(DT_WSTR,6) "String" String to unicode
(DT_I4) "20" String to integer
Convert string to date
(dt_date) "1900-01-01"
(dt_date) "1900-01-01 12:01:01"
Get first day of current month
dateadd("mm", datediff("mm",(dt_date) "1900-01-01", getdate()), (dt_date) "1900-01-01")
Get month number for current date
datepart("mm", getdate())
Return the first day of the current month
dateadd("mm", datediff("mm",(dt_date) "1900-01-01", getdate()), (dt_date) "1900-01-01")
Conditional. If day number of the current date before the 10th of the month give end of previous month otherwise return the 10th of the current month
dateadd("dd",
datepart("dd",getdate())>10?9:-1,
dateadd("mm", datediff("mm",(dt_date) "1900-01-01", getdate()), (dt_date) "1900-01-01")
)
Return the current date without the time - the previous midnight
dateadd("dd", datediff("dd",(dt_date) "1900-01-01", getdate()), (dt_date) "1900-01-01")
home