如何为'where'getdate()写条件 [英] How to write condition for 'where' getdate()
本文介绍了如何为'where'getdate()写条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道编写'where'条件的正确查询语法,它能够从datetime参数'Activedate'检索等于今天日期的数据记录。
$例如,b $ b,我尝试了以下查询,但我一直没有记录 - 请进一步建议。
非常感谢
我尝试过:
I would like to know correct query syntax for writing a 'where' condition, where its able to retrieve data records that equals today's date from datetime paramater 'Activedate'.
for example, i have tried the following queries but i keep getting no records - please advise further.
Many thanks
What I have tried:
select * from [dbo].[StoryTbl] where [ACTIVEDATE] = CONVERT (date, GETDATE())
select * from [dbo].[StoryTbl] where ACTIVEDATE = getDate()
select * from [dbo].[StoryTbl] where ACTIVEDATE = Dateadd(day,datediff(day,0,getdate()),0)
推荐答案
尝试这样的事情:
Try something like this:
SELECT
*
FROM
dbo.StoryTbl
WHERE
ActiveDate >= Convert(date, GetDate())
And
ActiveDate < DateAdd(day, 1, Convert(date, GetDate()))
;
这篇关于如何为'where'getdate()写条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文