Skip to content
Loading
  • Malvik Bhavsar
    +1
    Dear Dhoni,
     
    This is because of your date column have DateTime datatype. so you need to convert date into in your where condition.
     
    Please check the following example for more clarification. 
     
    1. DECLARE @Bill TABLE  
    2. (  
    3. BillDate date  
    4. )  
    5. INSERT INTO @Bill (BillDate)  
    6. VALUES  
    7. ('2020-01-22'),  
    8. ('2020-01-23'),  
    9. ('2020-01-24'),  
    10. ('2020-01-25')  
    11.  SELECT * FROM @Bill WHERE BillDate BETWEEN '2020-01-22' and '2020-01-25'  
    12.  go  
    13. -----------  
    14. DECLARE @Bill TABLE  
    15. (  
    16. BillDate datetime  
    17. )  
    18. INSERT INTO @Bill (BillDate)  
    19. VALUES  
    20. ('2020-01-22 00:00:00.000'),  
    21. ('2020-01-23 00:00:00.000'),  
    22. ('2020-01-24 00:00:00.000'),  
    23. ('2020-01-25 15:00:00.000')  
    24.  SELECT * FROM @Bill WHERE convert(date, BillDate) BETWEEN '2020-01-22' and '2020-01-25'  
    +1
  • Amit Gupta
    +1
    There are two option that you can use
    1. If column is of datetime
     
    1. SELECT * FROM Bill WHERE Date    
    2. >= CAST('2018-01-22 00:00:00.000' AS datetime) and date <= CAST('2020-01-25 23:59:59.999' AS datetime)  
    2.  Converting the datetime value to date and execute the query
    +1
  • Amit Gupta
    0
    Is the datatype of date column is date?
    0
  • Jignesh Kumar
    0
    Hey, Please use this link, https://stackoverflow.com/questions/24192166/sql-server-how-to-select-records-with-specific-date-from-datetime-column
    0
  • Vrushali Ghodke
    0
    hi, dhoni try out this quey SELECT * FROM Bill WHERE Date >= '2020-01-22' and Date <= '2020-01-25'
    0
  • Harsh Shah
    0
    You must try this query.
     
    select * from Exam where ExamDate >= '2020-01-22' and ExamDate <= '2020-01-25' 
    0
  • 0
    Hi 
    Malvik Bhavsar Sir
     
    I was use Group By  ; Some records not retriew
    0
  • 0
    Hi, 
    Amit Gupta  sir
     
    It was DateTime Data type 
    0