Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Write a date back to a table in an expression

Author  Topic 

stapsey
Starting Member

3 Posts

Posted - 2008-03-12 : 18:15:51
Help,

I have a package that maps the current getdate to a variable.

I then want to be able to write that variable back to a table using a sql task using the following expression:

"INSERT INTO CONTROL_BATCH_HEADER VALUES (
" + (DT_STR, 10, 1252) @[Control::intAdtBatchId] + ",
'" + @[Control::strSubjectArea] + "',
convert(datetime, '" + (DT_STR, 30, 1252) @[Control::dteRunDate] + "',131))"


The problem is the date is being written back in the wrong format. I've tried changing the mask to 121 but the month is being written as the day.

Help, how can I make this work regardless of the locals. In oracle I would just put a to_char(date,'dd-mm-yyyy') but not sure what to do here.

Thanks for your help

Stapsey

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-03-12 : 18:35:17
In SQL you may have to set the dateformat before you pass that...in some cases in depends on regional settings for the server box as to how it percieves the date order.

SET DATEFORMAT = YDM or
SET DATEFORMAT = YMD






Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page
   

- Advertisement -