Hi
I have below code and in some case if it returns 01-01-1900 it should be shown as ''
(SELECT TOP 1 [LastSessionDate] FROM [View_Session_Count_Report] where StudentID = t.StudentId) [LastSessionTDate]
Thanks
Hi
I have below code and in some case if it returns 01-01-1900 it should be shown as ''
(SELECT TOP 1 [LastSessionDate] FROM [View_Session_Count_Report] where StudentID = t.StudentId) [LastSessionTDate]
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tuhin PaulPosted Jun 10, 2023, 11:15 AM
Replace [View_Session_Count_Report] with the actual table name, and [YourTableName] with the name of the table you're querying from. The CASE statement checks if the LastSessionDate is equal to '1900-01-01', and if so, it returns an empty string. Otherwise, it returns the actual LastSessionDate.
Vishal YelvePosted Jun 8, 2023, 7:18 AM
(SELECT TOP 1 CASE
WHEN [LastSessionDate] = '1900-01-01' THEN ' '
ELSE [LastSessionDate] END AS [LastSessionTDate]
FROM [View_Session_Count_Report]
WHERE StudentID = t.StudentId) LastSessionTDate
Amit MohantyPosted Jun 8, 2023, 5:38 AM
Ramco RamcoPosted Jun 7, 2023, 4:57 PM
Hi Rupesh
It is still showing 01-01-1900
Thanks
Rupesh KahanePosted Jun 7, 2023, 4:36 PM
Try this one
SELECT TOP 1
Case when [LastSessionDate] = 01-01-1900 Then '' Else [LastSessionDate] End As [LastSessionDate]
FROM [View_Session_Count_Report] where StudentID = t.StudentId) [LastSessionTDate]