Thanks for the clarification David.
Arnie Rowland, Ph.D.
Most good judgment comes from experience.
Most experience comes from bad judgment.
top yourself.
- H. Norman Schwarzkopf
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message
news:1164453678.557202.5010@l12g2000cwl.googlegroups.com...
> David Portas wrote:
>>
>> Don't rely on implicit date conversion from strings if you can avoid
>> it. Here's an alternative:
>>
>> CREATE FUNCTION dbo.EncodeDate
>> ( @Year SMALLINT,
>> @Month TINYINT,
>> @Day TINYINT
>> )
>> RETURNS DATETIME
>> AS
>> BEGIN;
>> RETURN
>> DATEADD(DAY,@Day-1,
>> DATEADD(MONTH,@Month-1,
>> DATEADD(YEAR,@Year-2000,'20000101')));
>> END;
>> GO
>>
>
> Note that '20000101' is a "safe" date format. It will work irrespective
> of the server's regional settings. The same is not true of the format
> using / as a separator.
>
> --
> David Portas, SQL Server MVP
>
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
>
> SQL Server Books Online:
>
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>