Sql-server – UTC date in DMV dm_broker_queue_monitors

date formatservice-brokersql serversql-server-2008sql-server-2008-r2

It seems that the DMV dm_broker_queue_monitors returns UTC time rather than local time. Why is it so?

I am wondering how to get local time from this view? I can get current time offset, but that is not valid for older dates (before daylight saving), so it is not really a correct way to do that.

Best Answer

To get local time, your best bet is to use the CLR, if that is available to you. Matt Whitfield and Slawomir Brys have sample code you could use to convert which can handle Daylight Savings Time.

Regarding why the DMV is in UTC rather than local time, Service Broker can work across instances, so having service broker-related functionality all in UTC makes sense--that way, there isn't a problem with date synchronization between your east coast server and Tokyo branch. That'd be my best guess as to why that particular DMV is in UTC whereas a number of others (e.g., dm_exec_sessions) are in local time.