我想要完成两件事。
列表我想以下列格式('2007-05-28 00:00:00')将日期时间传递到我的存储过程中,但除非我使用{ts',否则这似乎不起作用2007-05-28 00:00:00'}
接下来我想将@SEAL_DATE增加一秒钟,以便它可以用来检查输入时间和之后一秒之间的日期。
提前致谢
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[getSealRecordDate] (@SEAL_DATE DATETIME)
AS
-- Declare variables
SELECT DISTINCT "FGFSTRANSFERS"."CONSIDERATION", "FGFSTRANSFERS"."AMOUNT_TRANSFER", "FGFSTRANSFERS"."DATE", "FGFSTransferDetails"."TRANSFER_ID", "FGFSTRANSFERS"."TRANSFER_ID", "FGFSTRANSFERS"."Curr", "FGFSTransferDetails"."CURR", "FGFSCUSTOMERS"."CMF_NAME_1", "FGFSCUSTOMERS"."CMF_NAME_2"
FROM ("FGFSInvestment"."dbo"."FGFSTransferDetails" "FGFSTransferDetails" INNER JOIN "FGFSInvestment"."dbo"."FGFSTRANSFERS" "FGFSTRANSFERS" ON "FGFSTransferDetails"."TRANSFER_ID"="FGFSTRANSFERS"."TRANSFER_ID") INNER JOIN "FGFSInvestment"."dbo"."FGFSCUSTOMERS" "FGFSCUSTOMERS" ON "FGFSTRANSFERS"."CUSTODIAN"="FGFSCUSTOMERS"."CMF_ACCOUNT"
WHERE ("FGFSTRANSFERS"."DATE">= @SEAL_DATE AND "FGFSTRANSFERS"."DATE"<{ts '2007-05-28 00:00:01'})
-- EXEC getSealRecordDate {ts '2007-05-28 00:00:00'}
伪SQL 所以它应该是:WHERE(“FGFSTRANSFERS”。“DATE”&gt; = @SEAL_DATE和“FGFSTRANSFERS”。“DATE”&lt; @ SEAL_DATE + 1秒)&lt; - 类似的东西
答案 0 :(得分:1)
DATEADD(second, 1, @SEAL_DATE)
答案 1 :(得分:1)
看看How Does Between Work With Dates In SQL Server?
使用dateadd添加第二个
select dateadd(second,1,'20090625 00:00:00.000')
答案 2 :(得分:0)
对于第二部分,请使用DATEADD
DateAdd(second,1,@ DateVariable)