Skip to content
Loading
  • Rajeesh Menoth
    0
    Hi,
     
    Use between operator or like this : 
    1. select * from userinfowhere [LoadDate]>= '01/10/2016' and [LoadDate]<= '02/10/2016'  
    Or
     
    1. select * from userinfowhere [LoadDate] between  '01/10/2016' and  '02/10/2016'   
     
     
    Reference : 
     
    http://stackoverflow.com/questions/5125076/sql-query-to-select-dates-between-two-dates 
    0
  • 0
    please it from your end
    using this query i didn't get last date data
    0
  • Rajeesh Menoth
    0
    Hi,
     
    Check my updated answer. 
     
    or
     
    Use Between Operator.
    1. select * from userinfowhere [LoadDate] between  '01/10/2016' and  '02/10/2016'   
    Reference :
     
    http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_between
    0
  • 0
    only i get the result of 01/10/2016
    0
  • Rajeesh Menoth
    0
    Hi,
    Please check your code properly.
    Demo :
    https://www.techonthenet.com/sql/between_try_sql.php
    https://www.techonthenet.com/sql/between.php
    0
  • 0
    i checked it
    0
  • 0
    i checked it
    if the query is
    select * from userinfo where [LoadDate] between '01/10/2016' and '02/10/2016'
    i get only the data of01/10/2016
    if i wnat to get01/10/2016 to 03/10/2016'
    then the query is
    select * from userinfo where [LoadDate] between '01/10/2016' and '04/10/2016'
    but this is not right way
    0
  • Midhun Tp
    0
    Hi,
    It may be because, you are using datetime column and comparing it with date only. Please try below query -
    select * from userinfo WHERE
    convert(DATE,[LoadDate]) >='2016/10/01' and convert(DATE,[LoadDate]) <='2016/10/03'
    0
  • Nitin Sontakke
    0
    Please try to understand how query is seen by SQL Server. It looks as follows:
    WHERE [LoadDate]>='2016/10/01 00:00:00' and [LoadDate]<='2016/10/03 00:00:00'
    If you notice, the load date in later part of query is just the beginning of the 3rd October. The entire day is not covered in this query. Instead if you give explicit query as follows, it works:
    WHERE [LoadDate]>='2016/10/01 00:00:00' and [LoadDate]<='2016/10/03 23:59:59'
    Hope it helps!
    0
  • Ananth G
    0
    try this
    1. select * from userinfo where Convert(Datetime,loaddate,111)>= CONVERT(Datetime, '2016/10/01', 103) and Convert(Datetime,loaddate,111) <=CONVERT(Datetime, '2016/10/03', 103)  
    0