Click here to Skip to main content
15,914,416 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Frds Good Morning,
I have a retrieve values from table by using "From Date" and "To Date".....I used this query
SQL
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'

but in this query its not retrieving 1st august ...Display 2nd august to 13 august...But I need from 1st August to 13th August
Posted
Updated 13-Aug-12 18:36pm
v3

Ignore time from date/time field, compare just date.

eg.
SQL
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!
:)
 
Share this answer
 
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'
 
Share this answer
 
HI

try Below Query
SQL
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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900