SQL,其中datetime列等于今天的日期? [英] SQL where datetime column equals today's date?

查看:589
本文介绍了SQL,其中datetime列等于今天的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  SELECT [Title],可以使用什么功能从db创建日期的日期记录? [名字],[姓氏],[公司名称],[兴趣] 
FROM [dbo]。[EXTRANET_users]
WHERE DATE(Submission_date)= DATE(NOW())

这不能使用sql server 2000,提交日期是日期时间字段

解决方案

看起来你正在使用SQL Server,在这种情况下, GETDATE() current_timestamp 可能会帮助您。但是您必须确保与系统日期进行比较的日期格式匹配(时区,粒度等)。



例如

 其中convert(varchar(10),submission_date,102)
= convert(varchar(10),getdate(),102)


What function can I use to get records from a db where created date is today date?

SELECT [Title], [Firstname], [Surname], [Company_name], [Interest] 
FROM [dbo].[EXTRANET_users] 
WHERE DATE(Submission_date) = DATE(NOW())

This doesn't work im using sql server 2000 and submission date is a date time field

解决方案

Looks like you're using SQL Server, in which case GETDATE() or current_timestamp may help you. But you will have to ensure that the format of the date with which you are comparing the system dates matches (timezone, granularity etc.)

e.g.

where convert(varchar(10), submission_date, 102) 
    = convert(varchar(10), getdate(), 102)

这篇关于SQL,其中datetime列等于今天的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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