开发者

How to write a SQL query for user selected date range?

开发者 https://www.devze.com 2023-01-14 23:28 出处:网络
I am trying to write a query that will capture calls completed within 24 hours and calls completed > 24 hours, by call rep, based off of user selected from date and to date range in a web form. I have

I am trying to write a query that will capture calls completed within 24 hours and calls completed > 24 hours, by call rep, based off of user selected from date and to date range in a web form. I have a 开发者_StackOverflow社区column for completion_date in the "yyyy-mm-dd 00:00:00" format, reps, type of call, call requested, and call assigned.

I really need some help!


If you're trying to figure out the query, something like this should work:

SELECT reps, completion_date
FROM dbo
WHERE completion_date < DATEADD(DAY, DATEDIFF(DAY, 0, @DateSelectedByUser), -1)

This should get you the results within 24 hours, now for the results over 24 hours, you just use > rather than <

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号