I have a log table of staff entrance and exit dates and time like below;
Number of items are different and all entries are in daily based. Minimum entry will be 2 because of entrance and exit logs.
I want to take only the start and end date from the logs. Please help me about the T-SQL query...
Another Simple Solution of your problem use Left and Right Function
DECLARE @str NVARCHAR(MAX)='11/12/2007 12:23,11/12/2007 21:22,11/12/2007 22:24'
SELECT LEFT(@str, CHARINDEX(',',@str) -1), Right(@str, CHARINDEX(',', Reverse(@str)) -1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With