dbTalk Databases Forums  

Please help with populating my fields

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Please help with populating my fields in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Learner
 
Posts: n/a

Default 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.

Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: Please help with populating my fields - 05-10-2004 , 11:04 AM






In similar situations, Style 101 (US) worked for me:

convert(varchar,orderdate,101)


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.