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)
 HOW TO CONVERT TO DATE

Author  Topic 

ramana123
Yak Posting Veteran

57 Posts

Posted - 2005-08-29 : 02:29:01


HI HERE I HAVE TO PASS THE DATE VALUE TO THE sp ..
WHILE TRY TO PASS THAT AS LIKE BELOW IT SHOWS ERROR AS

INVALID CONVERSAION VARCHAR TO DATE ..PLS HELP ME OUT..!!
DECLARE @A DATETIME
SET @A='22-1-2005'
EXEC CFG_WORKITEM_UPD @A,1

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-29 : 02:30:47
Pass it in yyyymmdd format

DECLARE @A DATETIME
SET @A='20050122'
EXEC CFG_WORKITEM_UPD @A,1

Madhivanan

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

ramana123
Yak Posting Veteran

57 Posts

Posted - 2005-08-29 : 02:34:35

hi thanks it s wporking fine but..
small doubt sqlserver defaultly take in the formatt of
yyyymmdd format ..
suppose i want give date like

ddmmyyyy then what i need to do..
Go to Top of Page

kapilarya
Yak Posting Veteran

86 Posts

Posted - 2005-08-29 : 02:49:22
try this

SET DATEFORMAT dmy
GO
DECLARE @datevar datetime
SET @datevar = '31/12/98'
SELECT @datevar
GO

Kapil Arya
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-29 : 02:51:11
you need to use format function in your Fron end application
or in SQL use convert function
Convert(varchar,Date,112)

Madhivanan

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

ramana123
Yak Posting Veteran

57 Posts

Posted - 2005-08-29 : 03:23:42
hi kapil..
it doesnt work what you have mentioned in aboue post..
i tried like this..
set dateformat dmy

set @a ='11032005'
but while try to execute the SP it shows the error like invlid conversion b/n varchar to date.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-29 : 03:38:02
Dont use DateFormat
Use the method I suggested

Madhivanan

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

- Advertisement -