Please help with populating my fields -
05-07-2004
, 10:11 AM
Hi,
I have a table whose DDL is given below:
CREATE TABLE [Orders] (
[OrdID] [int] ,
[OrderDate] [datetime] ,
[1OrderDateONLY] [datetime],
[1OrderDayName] [nvarchar] (15),
[1OrderMonth] [nvarchar] (25),
[1OrderDayOfMonth] [smallint] NULL ,
[1OrderWeekofYear] [smallint] NULL
)
GO
The field OrderDate contains both the Date and Time information.
What I want to do is populate the fields whose name start with a '1'
from the OrderDate field... I have tried all that I could think of but
nothing works. The last and the best try that I gave were the following
but get an error in both cases saying:
"The conversion of a char datatype to datetime datatype resulted in an
out of range datetime value"
1)
update orders
set orderdateonly=convert(varchar,orderdate,105),
orderDayname=datename(dw,orderdate),
orderMonth=datename(m,orderdate),
orderDayOfMonth=day(orderdate),
orderweekofyear=datename(wk,orderdate)
2)
update orders
set orderdateonly=
convert(datetime,convert(varchar,orderdate,105)),
orderDayname=datename (dw,orderdate),
orderMonth=datename (m,orderdate),
orderDayOfMonth=day(orderdate),
orderweekofyear=datename(wk,orderdate)
Can you PLEASE help. Many thanks in advance
--
Thanks. |