Skip to content

Instantly share code, notes, and snippets.

@kmoormann
Last active October 9, 2015 12:17
Show Gist options
  • Save kmoormann/3504218 to your computer and use it in GitHub Desktop.
Save kmoormann/3504218 to your computer and use it in GitHub Desktop.
ssis time string concatenation
(DT_WSTR, 4) YEAR( @[System::StartTime] )
+ "-"
+ (DT_WSTR, 1)( MONTH( @[System::StartTime] ) < 10 ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
+ (DT_WSTR, 4) MONTH ( @[System::StartTime] )
+ "-"
+ (DT_WSTR, 1)( DAY( @[System::StartTime] ) < 10 ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
+ (DT_WSTR, 4) DAY ( @[System::StartTime] )
+ " "
+ (DT_WSTR, 1)( DATEPART( "Hour" , @[System::StartTime] ) < 10 ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
+ (DT_WSTR, 2) DATEPART( "Hour" , @[System::StartTime] )
+ ":"
+ (DT_WSTR, 1)( DATEPART( "Minute" , @[System::StartTime] ) < 10 ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
+ (DT_WSTR, 2) DATEPART( "Minute" , @[System::StartTime] )
+ ":"
+ (DT_WSTR, 1)( DATEPART( "Second" , @[System::StartTime] ) < 10 ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
+ (DT_WSTR, 2) DATEPART( "Second" , @[System::StartTime] )
+ "."
+(DT_WSTR, 2)( DATEPART( "Millisecond" , @[System::StartTime] ) < 10 ? (DT_WSTR, 2)"00" : (DT_WSTR, 0)"" )
+ (DT_WSTR, 1)( ( DATEPART( "Millisecond" , @[System::StartTime] ) > 10 && DATEPART( "Millisecond" , @[System::StartTime] ) < 100 ) ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
+ (DT_WSTR, 2) DATEPART( "Millisecond" , @[System::StartTime] )
@kmoormann
Copy link
Author

(DT_WSTR, 4) YEAR( @[System::StartTime] )

  • "-"
  • (DT_WSTR, 1)( MONTH( @[System::StartTime] ) < 10 ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
  • (DT_WSTR, 4) MONTH ( @[System::StartTime] )
  • "-"
  • (DT_WSTR, 1)( DAY( @[System::StartTime] ) < 10 ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
  • (DT_WSTR, 4) DAY ( @[System::StartTime] )
  • " "
  • (DT_WSTR, 1)( DATEPART( "Hour" , @[System::StartTime] ) < 10 ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
  • (DT_WSTR, 2) DATEPART( "Hour" , @[System::StartTime] )
  • ":"
  • (DT_WSTR, 1)( DATEPART( "Minute" , @[System::StartTime] ) < 10 ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
  • (DT_WSTR, 2) DATEPART( "Minute" , @[System::StartTime] )
  • ":"
  • (DT_WSTR, 1)( DATEPART( "Second" , @[System::StartTime] ) < 10 ? (DT_WSTR, 1)"0" : (DT_WSTR, 0)"" )
  • (DT_WSTR, 2) DATEPART( "Second" , @[System::StartTime] )
  • "."
  • (DT_WSTR, 2)( DATEPART( "Second" , @[System::StartTime] ) < 10 ? (DT_WSTR, 2)"00" : (DT_WSTR, 0)"" )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment