sql从和到目前为止的相对值 [英] sql from and to date reterive values
本文介绍了sql从和到目前为止的相对值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨Frds早上好,
我使用"From Date"和"To Date"从表中检索值.....我使用此查询
Hi Frds Good Morning,
I have a retrieve values from table by using "From Date" and "To Date".....I used this query
select Invoice_Date,Sub_Total from Sales_Master where Customer_ID='1' and Invoice_Date >='8/01/2012 2:42:36 PM' and Invoice_Date <='8/13/2012 2:42:36 PM'
但在此查询中它没有检索到8月1日...显示8月2日至8月13日...但是我需要从8月1日至8月13日
but in this query its not retrieving 1st august ...Display 2nd august to 13 august...But I need from 1st August to 13th August
推荐答案
忽略时间日期/时间字段,仅比较日期.
例如.
Ignore time from date/time field, compare just date.
eg.
select convert(Datetime, CONVERT(VARCHAR(10),Invoice_Date ,105),105) as Invoice_Date
from tblInvoice
where convert(Datetime, CONVERT(VARCHAR(10),Invoice_Date ,105),105)>='8/01/2012'
and convert(Datetime, CONVERT(VARCHAR(10),Invoice_Date ,105),105)<='8/13/2012'
祝您编码愉快!
:)
Happy Coding!
:)
您正在设置从2:42:36 PM开始的时间,我认为您在2:42 PM之后的8月1日没有任何文件.因此,在这种情况下,如果不需要时间,您可以忽略时间.
从Sales_Master中选择Invoice_Date,Sub_Total,其中Customer_ID =''1''和Invoice_Date> =''8/01/2012''和Invoice_Date< =''2012/8/13''
You are setting time from 2:42:36 PM and i think you dont have any files on Aug 1 after 2:42 PM. So in that case you can ignore time if its not required..
select Invoice_Date,Sub_Total from Sales_Master where Customer_ID=''1'' and Invoice_Date >=''8/01/2012'' and Invoice_Date <=''8/13/2012''
HI
试试下面的查询
HI
try Below Query
select Invoice_Date,Sub_Total from Sales_Master where Customer_ID='1' and Invoice_Date >='01 Aug 2012 00:00:00' and Invoice_Date <='13 Aug 2012 23:59:59'
-Vijay
-Vijay
这篇关于sql从和到目前为止的相对值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文