You must Sign In to post a response.
  • Category: ASP.NET

    Date to date search working but some date show in middle

    date to date search working but some date show in middle ex :- 01-03-2018 to 30-03-2018 search

    working but some dates are entry between in two dates there also show in date search

    exp
    01-03-2018
    02-03-2018
    03-03-2018
    24-04-2018
    04-03-2018
    05-03-2018
    06-03-2018
    07-03-2018
    08-03-2018
  • #769511
    please post some more code to specify your problem so we can help you.
    in this code we can not understand your exact problem.

  • #769630
    Hi premkumarpeddinti,

    Please find the sample code in sql.

    -- SUBSTRING() function for older versions of SQL and SUBSTR() for newer versions of sql.

    create table #temp(empname varchar(50), dob datetime)
    insert into #temp values('Test1,'2018-03-01'),('Test2,'2018-04-24'),('Test3','2018-03-30')

    declare @fd as varchar(50) = '01-03-2018'
    set @fd = substring(@fd,7,4) + '-' + substring(@fd,4,2) + '-' + substring(@fd,1,2)

    declare @ld as varchar(50) = '30-03-2018'
    set @ld = substring(@ld,7,4) + '-' + substring(@ld,4,2) + '-' + substring(@ld,1,2)

    select empname, dob from #temp where cast(dob as date) between (cast(@fd as date)) and cast(@ld as date)

    Hope this will help you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"


  • Sign In to post your comments