DropTime在DateTime [英] Drop Time in DateTime

查看:86
本文介绍了DropTime在DateTime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,我的表格存储日期为

I have a problem where my table stores the date as

2009-01-10 10:00:00.000

我有另一个表将日期存储为

and I have another table which stores the date as

2009-01-10 12:00:00.000

我知道他们不一样,但日期是,SQL中有没有容易放下时间,只保留日期进行比较?谢谢。

I know they are not the same but the dates are, is there away in SQL to easily drop the time and keep just the dates for comparison? Thanks.

推荐答案

运行此

SELECT DATEADD(dd, DATEDIFF(d, 0, Getdate()), 0)

将Getdate()更改为您的列名称以剥离日期

change Getdate() to your column name to strip the date

如果您做一个比较,最好做> =和<因为它会更好地执行

BTW if you are doing a comparison it is better to do >= and < since it will perform better

这篇关于DropTime在DateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆