How to get data between a time range in mssql c#

  • 350 Views
  • Last Post 14 February 2019
[email protected] posted this 14 February 2019

I am having trouble on time range part I do date time between part as taught in your one of the youtube tutorial but I need the if I give today 6.00 AM to I specified day 6.00 AM all details between that time range should appear. Like in the below picture.

The details should come there. there is some error on that also I just used where

where request_end >= start_time
and   request_start <= end_time

this works but i don't know how to apply please help me with this issue please

advanced thanks

admin posted this 14 February 2019

To get data from date range in sql you can use the following sql query.

DECLARE @FromDate DateTime
DECLARE @ToDate DateTime
SELECT * 
FROM [Your_Table]
WHERE [CreateDate] BETWEEN @FromDate AND @ToDate

The sql query above that's help you select data from date range between two dates.

Close