2

In SSIS 2012 I can get current date using GETDATE() function with expression in variables.

Though, in SSIS 2008 expression fields does not exist.

Question: How can I get current date dynamically with variables in SSIS 2008?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Jungleman
  • 286
  • 2
  • 6
  • 20
  • Maybe you can use the system variable StartTime instead: https://msdn.microsoft.com/en-us/library/ms141788.aspx?f=255&MSPPError=-2147217396 – Tab Alleman Apr 28 '15 at 13:16

2 Answers2

9

Help me understand how GETDATE() doesn't exist in the SSIS Expression language for 2008.

enter image description here

That said, I find that using the system variable @[System::StartTime] preferable to GET_DATE(). StartTime provides a consistent point in time for the duration of a package. It will always be whenever the package begins execution. Contrast that with the value of GETDATE() which is right now. Now. NOW. Every time you inspect that value, it's subject to change. This can cause trouble you when you build a file name with second precision. Or if you want to group all the data that was inserted in a single run. You'll have drift in those values so you must use range queries to identify all the data in run X. Or you can use StartTime which is updated when the package begins to run but remains constant for the duration.

billinkc
  • 59,250
  • 9
  • 102
  • 159
  • 1
    Ok, so what is the trick to get the data inserted to SQL Server column type DateTime? I'm using DBTIMESTAMP as a parameter to a SQL SP and it is failing with 'invalid time format'. – Maa421s Mar 24 '16 at 19:41
  • Hi @Maa421s Sounds like you have a question. Care to post it as such? – billinkc Mar 24 '16 at 19:46
  • It's posted. The info on the differences between getdate() and System::StartTime were very enlightening. – Maa421s Mar 24 '16 at 19:56
2

Try this:

RIGHT( "00"+ (DT_WSTR, 2) DAY(GETDATE()),2)+RIGHT( "00"+ (DT_WSTR, 2) 
MONTH(GETDATE()),2)+(DT_WSTR, 4) YEAR(GETDATE())
juzraai
  • 5,693
  • 8
  • 33
  • 47