SSIS 2008 - Get Current Date in Variables

2020-02-14 10:44发布

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?

2条回答
2楼-- · 2020-02-14 11:16

Try this:

RIGHT( "00"+ (DT_WSTR, 2) DAY(GETDATE()),2)+RIGHT( "00"+ (DT_WSTR, 2) 
MONTH(GETDATE()),2)+(DT_WSTR, 4) YEAR(GETDATE())
查看更多
戒情不戒烟
3楼-- · 2020-02-14 11:26

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.

查看更多
登录 后发表回答