博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql查询当天记录_sql查询当天记录
阅读量:1532 次
发布时间:2019-04-21

本文共 714 字,大约阅读时间需要 2 分钟。

展开全部

1、SQL在查询当天记录时要注意是从62616964757a686964616fe59b9ee7ad9431333337623436当天的0点0分0秒0毫秒开始,到次日0点0分0秒0毫秒截止,但不包含次日的0点0分0秒0毫秒。

2、注意:在不同数据库产品中,获得当天日期的函数不一样。

MSSQL获得当前日期:convert(varchar(10),Getdate(),120)

MYSQL获得当前日期:date(now())

Oracle获得当前日期:to_char(sysdate,'yyyy-mm-dd')

Access获得当前日期:date()

3、在各个数据库里获得当天的记录写法为(假设表名为:Table_1,日期列名为:date_col):

MSSQL获得当天记录:select * from table_1 where date_col>=convert(varchar(10),Getdate(),120) and date_col

MYSQL获得当天记录:select * from table_1 where date_col>=date(now()) and date_col

Oracle获得当天记录:select * from table_1 where date_col>=to_char(sysdate,'yyyy-mm-dd') and date_col

Access获得当天记录:select * from table_1 where date_col>=date() and date_col

4、另外,在查询的时候,尽量不要对列进行运算,因为日期列上若有索引,就无法使用索引了。

转载地址:http://spkdy.baihongyu.com/

你可能感兴趣的文章
【MM模块】 Goods Receipt 收货 1
查看>>
【MM模块】 Goods Receipt 收货 2
查看>>
【MM模块】 Goods Receipt 收货 4
查看>>
【MM模块】Invoices in a Foreign Currency 汇率差异
查看>>
【转】ABAP BASE64编码与解码练习
查看>>
【MM模块】Taxes / Terms of Payment 税额和付款条件简介
查看>>
【MM模块】Blocking Reasons 冻结原因
查看>>
【MM模块】Invoice for POs with Acc Assignment 科目指派
查看>>
【MM模块】Subsequent Debits/Credits 事后借记/事后贷记
查看>>
【MM模块】Credit Memos and Reversals 红字发票和冲销
查看>>
如何控制参照PR作PO时,PO的数量不能超过PR的数量
查看>>
SAP PR 转 PO
查看>>
(MM)PR与PO的控制
查看>>
smartforms设置纸张打印格式
查看>>
【MM模块】ERS and Invoicing Plans 发票计划
查看>>
【MM模块】Releasing Blocked Invoices 释放冻结发票
查看>>
【MM模块】Batch 批次管理1
查看>>
将SmartForms转换为PDF保存到本地
查看>>
【MM模块】Batch 批次管理 2
查看>>
【MM配置】Batch Determination 批次决定
查看>>