如何在Azure SQL数据库中更改时区? [英] How to change the timezone in Azure SQL Database?

查看:190
本文介绍了如何在Azure SQL数据库中更改时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望使用C#解决方案来获取特定位置的日期:

We would like to get the date in a specific location, either by using something like the C# solution:

TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "West US Time");

或者通过设置Azure SQL数据库时区,然后使用getdate().

Or by setting the Azure SQL Database timezone and then using getdate().

推荐答案

从MSDN:使用

SELECT CONVERT(datetime, '03/29/2015 01:01:00')   
AT TIME ZONE 'Central European Standard Time';  
--2015-03-29 01:01:00.000 +01:00  

--Time between 02:00 and 03:00 is converted as +01!  
SELECT CONVERT(datetime, '03/29/2015 02:01:00')   
AT TIME ZONE 'Central European Standard Time';  
--2015-03-29 02:01:00.000 +01:00  

SELECT CONVERT(datetime, '03/29/2015 03:01:00')   
AT TIME ZONE 'Central European Standard Time';  
--2015-03-29 03:01:00.000 +02:00  

这篇关于如何在Azure SQL数据库中更改时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆