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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rupesh KahaneRank #136 · 16.4K reputationPosted Jun 7, 2023, 12:36 PM EDT
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]
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 7, 2023, 12:57 PM EDT
Hi Rupesh
It is still showing 01-01-1900
Thanks
Amit MohantyRank #112 · 20K reputationPosted Jun 8, 2023, 1:38 AM EDT
SELECT TOP 1 CASE WHEN [LastSessionDate] = '1900-01-01' THEN '' ELSE [LastSessionDate] END AS [LastSessionTDate] FROM [View_Session_Count_Report] WHERE StudentID = t.StudentIdVishal YelveRank #178 · 13.6K reputationPosted Jun 8, 2023, 3:18 AM EDT
(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
Tuhin PaulRank #7 · 71.9K reputationPosted Jun 10, 2023, 7:15 AM EDT
SELECT CASE WHEN (SELECT TOP 1 [LastSessionDate] FROM [View_Session_Count_Report] WHERE StudentID = t.StudentId) = '1900-01-01' THEN '' ELSE (SELECT TOP 1 [LastSessionDate] FROM [View_Session_Count_Report] WHERE StudentID = t.StudentId) END AS [LastSessionTDate] FROM [YourTableName] tReplace [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.