Hi - erm, I probably didn't explain well enough. I do know how to use convert and cast for different date formats - and anyway, char(10) format 103 is exactly my problem. That's dd/mm/yyyy but xp_cmdshell is reading that as mm/dd/yyyy and causing errors.
I have vb.net code that produces a page where the user can tick a box to select a report to run, and some reports have date parameters. So, the asp code picks up the characters typed for the date value - in the UK it means the user wants to type 20/12/2006 for example - and puts that into a variable. A stored procedure is run which places that variable into my data-select code; for example:
- select * from table where trandate=@aspdate
When the stored procedure is run in QA I can feed in 20/12/2006 and the statement works fine. When the stored procedure is run via xp_cmdshell (using isql or osql syntax) then those same characters are being read as month then day and it errors.
I have a workaround in that if the user types 20-dec-2006 then I can use that value in my syntax as:
- where trandate=cast(@aspdate as datetime)
and it all works again.
My issue is, there is some fundamental default US date format somewhere in our system. It ain't in QA, and the box on which SQL Server is installed appears to be fine with all UK regional settings. So, what is xp_cmdshell looking at, for it to do implicit conversions from aa/bb/cccc characters into an assumed mm/dd/yyyy date format?
Thanks, Sharon.