Question : Date Time with Sql 2005

How come this code doesn't work when I try to insert is as a datetime?

      DECLARE @Months AS datetime
            SET @Months = RTRIM(LTRIM((SELECT Months
            FROM x_TempUpload WHERE TempID = 376)))
            SET @Months = CONVERT(datetime,@Months,101)

PRINT @Months

no matter what numbers I put in I don't get any different format and my output is always:

May 30 2006 12:00AM

Which doesnt go into a datetime field.

Thanks

Answer : Date Time with Sql 2005

@Months is a datetime and so will print as your default display reprsentation.

try

select convert(varchar(30),@months, 112)
select convert(varchar(30),@months, 106)
select convert(varchar(30),@months, 103)

see the convert function in bol.
Random Solutions  
 
programming4us programming4us