We help IT Professionals succeed at work.

sql DateDiff help

I need to show the record that is 24 hours priors of session start.

CASE WHEN isNULL(s.repost,0) = 1 
		THEN 
			DateDiff(hh,SU.sessionStart,GETDATE()) 
		ELSE 
			datediff(d, getdate(), SU.sessionStart) 
		END
 >= CASE WHEN isNULL(s.repost,0) = 1 
		THEN 
			24
		ELSE 
			3
		END 

Open in new window

Comment
Watch Question

Database and Application Developer
Commented:
Select f1, f2
From (Select f1, f2,
CASE WHEN isNULL(s.repost,0) = 1 
		THEN 
			DateDiff(hh,SU.sessionStart,GETDATE()) 
		ELSE 
			datediff(d, getdate(), SU.sessionStart) 
		END As DateCriteria
From TableYouHave) As D (f1, f2, DateCriteria)
Where DateCriteria <=24

Open in new window

PortletPaulEE Topic Advisor
Most Valuable Expert 2014
Awarded 2013

Commented:
I'm sorry but I don't understand the question as the sql in the question make no sense from line 7 onward

Please remember that THE BEST WAY TO ASK  is to provide:

a. sample data
b. the expected result

If we understand the question easily you get an answer faster and you don't need to clarify the question for us.
awking00Information Technology Specialist

Commented:
select ...
where dateadd(d,1,SU.sessionStart) >= getdate()
Vitor MontalvãoIT Engineer
Distinguished Expert 2017

Commented:
erikTsomik, do you still need help with this question?