Steps to do:
1)
Create Stored Procedure (SP)[
^]
2) Copy And Paste below code into the body of SP:
CREATE TABLE #EmpInput (EmpName VARCHAR(30), DaTi SMALLDATETIME)
INSERT INTO #EmpInput (EmpName, DaTi)
SELECT 'Xing Zuber', '2013-07-13 09:10 PM'
UNION ALL SELECT 'Daving solman', '2013-07-13 09:08 PM'
UNION ALL SELECT 'Iyan Yokovich', '2013-07-12 09:00 PM'
UNION ALL SELECT 'Dev richardson', '2013-07-03 09:11 PM'
UNION ALL SELECT 'Xing Zuber', '2013-07-03 09:16 PM'
UNION ALL SELECT 'Xing Zuber', '2013-07-11 09:02 PM'
UNION ALL SELECT 'Dev richardson', '2013-07-11 09:15 PM'
DECLARE @cols VARCHAR(300)
DECLARE @dt VARCHAR(1000)
DECLARE @pt VARCHAR(4000)
SET @cols = STUFF((SELECT DISTINCT '],[' + CONVERT(VARCHAR(10),DaTi,121)
FROM #EmpInput
ORDER BY '],[' + CONVERT(VARCHAR(10),DaTi,121)
FOR XML PATH('')),1,2,'') + ']'
SET @dt = N'SELECT EmpName, CONVERT(VARCHAR(10),DaTi,121) AS IDate, CONVERT(VARCHAR(10),DaTi,108) AS ITime
FROM #EmpInput'
SET @pt = N'SELECT EmpName, ' + @cols + ' ' +
'FROM (' + @dt + ') AS DT ' +
'PIVOT(MAX(ITime) FOR IDate IN(' + @cols + ')) AS PT '
EXEC(@pt)
DROP TABLE #EmpInput
3) Change the code to your needs
4)
Call SP from ASP.NET code behind[
^] and bind result to a gridview ;)
End ;)