Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 如何通过过程从数据库中获取特定日期的记录。日期作为参数传递_Sql Server_Date - Fatal编程技术网

Sql server 如何通过过程从数据库中获取特定日期的记录。日期作为参数传递

Sql server 如何通过过程从数据库中获取特定日期的记录。日期作为参数传递,sql-server,date,Sql Server,Date,这是我的程序我无法获得特定日期的记录 我有特定日期的数据,但输出为零。。 但是当我使用>=时,它会给我数据 使用=@Date作为参数时,输出为零 使用>=@Date作为参数将给出输出 我的程序根据提供的日期需要在哪里修改以获取数据 Declare @ids varchar(max); set @ids = (select ids from USers where UserId = 10) select F.Date as DateOfuser,F.ID , (B.Firs

这是我的程序我无法获得特定日期的记录

我有特定日期的数据,但输出为零。。 但是当我使用>=时,它会给我数据

使用=@Date作为参数时,输出为零

使用>=@Date作为参数将给出输出

我的程序根据提供的日期需要在哪里修改以获取数据

Declare @ids varchar(max);    
set @ids = (select ids from USers where UserId = 10)      
  select F.Date as DateOfuser,F.ID , (B.FirstName + ',' + B.LastName) as Name,    
A.Group ,E.companyname,E.company ,D.receivedDate    
from Details as A    
inner join Usersnew as B    
on A.newId = B.newId    
inner join Files as D    
on D.DocId = B.Docid    
Inner join PDetails as C    
on (D.GId = c.GId and D.PId = C.Id and D.IsActive='True' and             
(convert(datetime,D.ReceivedDate, 20) = @Date  ))  -- @parameter @date // no output       
and D.GId in(select ID from fnSplitter(@ids))    
inner join PDetails as E    
on E.PId = C.Id    
inner join Information as F    
on F.PId = E.PId
如何获取作为参数传递的特定日期的记录

我有数据,但它没有返回。我如何修改我的过程以获取数据 数据

我需要根据日期获取输出..我通过日期接收数据,所以日期作为参数传递

请帮忙

有没有办法获取作为参数传递的特定日期的记录

为什么

=未返回>=正在返回

你能解释一下吗


我们能不能在过程中传递=等于传递日期的操作数?

正如@Simon所说。比较日期和日期时间可能有问题。当您将日期与日期时间进行比较时,日期被转换为日期时间,例如2017-07-04被转换为2017-07-04 00:00.000。 换行:

    on (D.GId = c.GId and D.PId = C.Id and D.IsActive='True' and             
(convert(datetime,D.ReceivedDate, 20) = @Date  ))
致:


可能是日期与日期时间的问题。尝试将这两个参数包装在代码中,以去除这两个参数的时间,例如DATEADDd、0、DateDiffed、0、D.ReceivedDate,并对日期参数执行相同的操作
on (D.GId = c.GId and D.PId = C.Id and D.IsActive='True' and
(convert(datetime,D.ReceivedDate, 20) >= @Date) AND (convert(datetime,D.ReceivedDate, 20) < DATEADD(dd,1,@Date)))
on (D.GId = c.GId and D.PId = C.Id and D.IsActive='True' and             
(cast(D.ReceivedDate as date) = @Date  ))