Skip to content

Instantly share code, notes, and snippets.

@belenaj
Last active November 22, 2017 13:07
Show Gist options
  • Save belenaj/9e22d05bcf202cf79374ebdbfe0ff809 to your computer and use it in GitHub Desktop.
Save belenaj/9e22d05bcf202cf79374ebdbfe0ff809 to your computer and use it in GitHub Desktop.
SSIS | Generate Datekey (int) from Date field #SSIS #date #YYYYMMDD

SSIS | Generate Datekey (int) from Date field

This expression will extract the date from the field in format YYYYMMDD and it will be converted to integer

i.e. '2017-01-03 13:18:13.667' --> 20170103 (int) Just replace for your field name

(DT_I4)((DT_WSTR,4)(DATEPART("yyyy", <datetime>)) + 
RIGHT("0" + (DT_WSTR,2)DATEPART("mm", <datetime>), 2) + 
RIGHT("0" + (DT_WSTR,2)DATEPART("dd", <datetime>), 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment