Skip to content

Commit 564543f

Browse files
authored
Merge pull request #9980 from MicrosoftDocs/MashaMSFT-patch-2
updated example 3
2 parents 2f7c4d7 + 6e0cdd0 commit 564543f

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

docs/t-sql/functions/todatetimeoffset-transact-sql.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "TODATETIMEOFFSET (Transact-SQL) | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "03/13/2017"
4+
ms.date: "04/22/2019"
55
ms.prod: sql
66
ms.prod_service: "database-engine, sql-database, sql-data-warehouse, pdw"
77
ms.reviewer: ""
@@ -60,30 +60,27 @@ TODATETIMEOFFSET ( expression , time_zone )
6060
### A. Changing the time zone offset of the current date and time
6161
The following example changes the zone offset of the current date and time to time zone `-07:00`.
6262

63-
```
63+
```sql
6464
DECLARE @todaysDateTime datetime2;
6565
SET @todaysDateTime = GETDATE();
6666
SELECT TODATETIMEOFFSET (@todaysDateTime, '-07:00');
67-
-- RETURNS 2007-08-30 15:51:34.7030000 -07:00
67+
-- RETURNS 2019-04-22 16:23:51.7666667 -07:00
6868
```
6969

7070
### B. Changing the time zone offset in minutes
7171
The following example changes the current time zone to `-120` minutes.
7272

73-
```
74-
DECLARE @todaysDate datetime2;
75-
SET @todaysDate = GETDATE();
76-
SELECT TODATETIMEOFFSET (@todaysDate, -120);
77-
-- RETURNS 2007-08-30 15:52:37.8770000 -02:00
73+
```sql
74+
SELECT TODATETIMEOFFSET(SYSDATETIME(), -120)
75+
-- RETURNS: 2019-04-22 11:39:21.6986813 -02:00
7876
```
7977

8078
### C. Adding a 13-hour time zone offset
8179
The following example adds a 13-hour time zone offset to a date and time.
8280

83-
```
84-
DECLARE @dateTime datetimeoffset(7)= '2007-08-28 18:00:30';
85-
SELECT TODATETIMEOFFSET (@dateTime, '+13:00');
86-
-- RETURNS 2007-08-28 18:00:30.0000000 +13:00
81+
```sql
82+
SELECT TODATETIMEOFFSET(SYSDATETIME(), '+13:00')
83+
-- RETURNS: 2019-04-22 11:39:29.0339301 +13:00
8784
```
8885

8986
## See Also

0 commit comments

Comments
 (0)