[dba-SQLServer] Passing a valid date to a sproc

Stuart McLachlan stuart at lexacorp.com.pg
Thu Oct 2 23:55:25 CDT 2008


Unfortunately, 103 etc is for converting from DATETIME to a string, not the 
other way round.

IF you are stuck with passing "dd/mm/yyyy" you will have to do something 
like

@WeekEnding  CHAR(10)
....

DIm @WeekEndingDate DATETIME
....
@WeekEndingDate = SUBSTRING ( @WeekEnding , 4 , 2 ) 
       + '/' + SUBSTRING (  @Weekending , 1 , 2 ) 
       + '/' +SUBSTRING (  @Weekending , 7 , 4 ) 
......
VALUES(
.....
@WeekEndingDate
......



 





> 
> Ok....  Found this in help "CONVERT(DATETIME, '7/19/1996', 103)" and
> it looks promising, but I have no idea where to put it into the sproc
> to make it actually work.  All my attempts have been rather pathetic
> and ended in total and abject failure.  The example shown in help is
> related to a query rather than fixing it up in a sproc - all rather
> new to this so sorry if this is a dumb question. hmmm.. :-/ 




More information about the dba-SQLServer mailing list