I have a process that runs on a SQL server that is set to Eastern time, when the process it completed we populate a table with the completion time. I have a view that is currently being used by multiple applications which displays the Date/Time of the process in different columns, since this is being used by other apps I can’t change the view.
The query I use to return my process data is below and the Date/Time are being converted to a varchar on the server side – so it isn’t coming to the UI as a date/time.
SELECT CONVERT(VARCHAR(10), A2.TaskDateTime, 101) AS TaskDate,
CONVERT(VARCHAR(5), A2.TaskDateTime, 108) AS TaskTime
FROM Task AS T2
JOIN Application_Task AS A2
ON A2.TaskID = T2.TaskID
This data is then being displayed in the UI via a datagridview. I am trying to format the time column in a DataGridView to my local time zone because the users will be in different time zones.
I have looked at DataGridViewCellStyle.Format and search SO and found this on converting to local time but that is parsing one string. I can’t seem to figure out how to apply that to the entire column of data.
I would appreciate any help and/or direction on where to begin with this.
I handle this in CellFormatting event: