Avatar of erikTsomik
erikTsomikFlag for United States of America

asked on 

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

Microsoft SQL ServerMicrosoft SQL Server 2008SQL

Avatar of undefined
Last Comment
Vitor Montalvão
ASKER CERTIFIED SOLUTION
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of PortletPaul
PortletPaul
Flag of Australia image

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.
Avatar of awking00
awking00
Flag of United States of America image

select ...
where dateadd(d,1,SU.sessionStart) >= getdate()
erikTsomik, do you still need help with this question?
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo