This is SQL Scrip
/************************************************** ****
Tables Begin
************************************************** ****/
----------------
-- dbo.TABLE1
----------------
CREATE TABLE [dbo].[TABLE1]
(
[Day] DATETIME NOT NULL,
[Value_1] DECIMAL(18, 2) NOT NULL,
[Value_2] DECIMAL(18, 0) NOT NULL,
[Grup] VARCHAR(1) NOT NULL
);
GO
/************************************************** ****
Tables End
************************************************** ****/
/************************************************** ****
Stored procedures Begin
************************************************** ****/
CREATE PROCEDURE [dbo].[SP_2]
AS
GO
/************************************************** ****
Stored procedures End
************************************************** ****/
/************************************************** ****
Stored procedures Begin
************************************************** ****/
----------------
-- dbo.SP_2
----------------
ALTER PROCEDURE SP_2(@.datainceput datetime, @.datasfirsit datetime)
As
set nocount on
DECLARE @.NEWLINE AS char(1)
SET @.NEWLINE = CHAR(10)
DECLARE @.keyssql AS varchar(1000)
SET @.keyssql = 'SELECT * FROM Table1'
+ @.NEWLINE + 'WHERE'
+@.NEWLINE + '[Day] BETWEEN ' + CONVERT(DATETIME, @.datainceput , 104) + ' AND ' + CONVERT(DATETIME, @.datasfirsit , 104)
EXEC (@.keyssql)
GO
/************************************************** ****
Stored procedures End
************************************************** ****/Try this and tell me what you get
Alter Procedure "Selectie_Date_Tabel" (@.datainceput varchar(10), @.datasfirsit varchar(10),@.Grupa AS nvarchar(20))
As
set nocount on
DECLARE @.NEWLINE AS char(1)
SET @.NEWLINE = CHAR(10)
DECLARE @.keyssql AS varchar(1000)
SET @.keyssql = 'SELECT * FROM View2'
+ @.NEWLINE + 'WHERE [Cod grupa] = ' + CHAR(39) + @.Grupa + CHAR(39)
+ @.NEWLINE + 'AND ([Day] BETWEEN ' + CONVERT(DATETIME, @.datainceput , 104) + ' AND ' + CONVERT(DATETIME, @.datasfirsit , 104) +')'
EXEC (@.keyssql)|||Im sory, don't work
01.01.2004
02.02.2004
this is the date format which I use.
My Computer Regional setting: ShortDate: dd.mm.yyyy
It is possible that I'm wrong, but I find the solution:
THANK FOR YOUR HELP
Alter PROCEDURE SP_2(@.datainceput datetime, @.datasfirsit datetime)
As
set nocount on
DECLARE @.NEWLINE AS char(1)
SET @.NEWLINE = CHAR(10)
DECLARE @.keyssql AS varchar(1000)
declare @.Date_Begin as varchar(21)
set @.Date_Begin= CHAR(39) + convert(char(19),@.datainceput,120)+ CHAR(39)
declare @.Date_End as varchar(21)
set @.Date_End= CHAR(39)+ convert(char(19),@.datasfirsit,120)+ CHAR(39)
SET @.keyssql = 'SELECT * FROM Table1'
+ @.NEWLINE + 'WHERE'
+@.NEWLINE + '[Day] BETWEEN CONVERT(DATETIME,' + @.Date_Begin + ', 102)' + ' AND CONVERT(DATETIME,' + @.Date_End +' , 102)'
Print @.keyssql
EXEC (@.keyssql)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment