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
 General SQL Server Forums
 New to SQL Server Programming
 datetime sql

Author  Topic 

marclas
Starting Member

16 Posts

Posted - 2012-05-16 : 16:46:22
hi,
i have this sql proc


CREATE PROCEDURE dbo.ListeLettreFichier
-- Add the parameters for the stored procedure here
@DateDebut datetime,
@DateFin datetime
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
SELECT dbo.CSR_FILE.FIL_NAMESEND
FROM dbo.CSR_FILE
WHERE FIL_DATESEND between @DateDebut and @DateFin
END
GO

when i excecute , i got this error
USE [RECLACSR-DB]
GO

DECLARE @return_value int

EXEC @return_value = [dbo].[ListeLettreFichier]
@DateDebut = 2012/05/01,
@DateFin = 2012/05/30

SELECT 'Return Value' = @return_value

GO
Msg 102, Level 15, State 1, Line 5
Syntaxe incorrecte vers '/'.
can you pliz help...

Marclas

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-05-16 : 16:50:35
You have to represent your date like a string for assignment:
EXEC @return_value = [dbo].[ListeLettreFichier]
@DateDebut = '2012/05/01',
@DateFin = '2012/05/30'
Also, you should use an unambiguous (ISO) date format.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-16 : 20:16:28
you may be better off passing dates as 20120501 rather than adding -,/ etc to make it locale independent

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-05-18 : 09:19:29
More information
http://beyondrelational.com/modules/2/blogs/70/posts/10898/understanding-datetime-column-part-ii.aspx

Madhivanan

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

- Advertisement -