Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Convert to date in stored procedure

Author  Topic 

mcordewener
Starting Member

19 Posts

Posted - 2005-10-10 : 08:23:04
Hi,

I am trying to create a new procedure:

CREATE PROCEDURE [dbo].[qry_v2_convert_date] AS
UPDATE b_tbl_vdat SET b_tbl_vdat.Usable_date = CONVERT(Date(Left(SCAPPTSEG-TST_FROM,10));
From b_tbl_vdat
Go

What do i do wrong, the SQL Server keeps beeping on a wrong left function.

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-10-10 : 08:30:56
Try this..
CONVERT(Date,(Left(SCAPPTSEG-TST_FROM,10)))

Complicated things can be done by simple thinking
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-10 : 08:37:28
What is the Data type of Usable_date?
If it is DateTime or SmallDateTime then there is no need to convert it

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mcordewener
Starting Member

19 Posts

Posted - 2005-10-10 : 08:38:07
Thank You,

it works

CREATE PROCEDURE [dbo].[qry_v2_convert_date] AS
UPDATE b_tbl_vdat SET b_tbl_vdat.Usable_date = CONVERT(smalldatetime,(Left([b_tbl_vdat].[SCAPPTSEG-TST_FROM],10)))
From b_tbl_vdat
Go

I needed to declare the tablename and a different Datetype.

Thnx
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-10 : 08:40:46
I repeat what I asked you
What is the Data type of Usable_date?
If it is DateTime or SmallDateTime then there is no need to convert it


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mcordewener
Starting Member

19 Posts

Posted - 2005-10-10 : 08:43:22
The field needs to be updated from varchar to a date value, the download happens from SAP - Txt file to an SQL server import.

Marcel Cordewener

quote:
Originally posted by madhivanan

I repeat what I asked you
What is the Data type of Usable_date?
If it is DateTime or SmallDateTime then there is no need to convert it


Madhivanan

Failing to plan is Planning to fail



Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-10 : 08:48:55
Then Convert is the only way

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -