Skip to content

Commit a88bcf0

Browse files
authored
Specifying language for code blocks
1 parent 756d6c3 commit a88bcf0

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

docs/t-sql/data-types/time-transact-sql.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-s
102102

103103
When the conversion is to **time(n)**, the hour, minute, and seconds are copied. When the destination precision is less than the source precision, the fractional seconds is rounded up to fit the destination precision. The following example shows the results of converting a `time(4)` value to a `time(3)` value.
104104

105-
```
105+
```sql
106106
DECLARE @timeFrom time(4) = '12:34:54.1237';
107107
DECLARE @timeTo time(3) = @timeFrom;
108108

@@ -120,7 +120,7 @@ SELECT @timeTo AS 'time(3)', @timeFrom AS 'time(4)';
120120

121121
When the conversion is to **datetime**, hour, minute, and second values are copied; and the date component is set to '1900-01-01'. When the fractional seconds precision of the **time(n)** value is greater than three digits, the **datetime** result will be truncated. The following code shows the results of converting a `time(4)` value to a `datetime` value.
122122

123-
```
123+
```sql
124124
DECLARE @time time(4) = '12:15:04.1237';
125125
DECLARE @datetime datetime= @time;
126126
SELECT @time AS '@time', @datetime AS '@datetime';
@@ -136,7 +136,7 @@ SELECT @time AS '@time', @datetime AS '@datetime';
136136

137137
When the conversion is to **smalldatetime**, the date is set to '1900-01-01', and the hour and minute values are rounded up. The seconds and fractional seconds are set to 0. The following code shows the results of converting a `time(4)` value to a `smalldatetime` value.
138138

139-
```
139+
```sql
140140
-- Shows rounding up of the minute value.
141141
DECLARE @time time(4) = '12:15:59.9999';
142142
DECLARE @smalldatetime smalldatetime= @time;
@@ -163,7 +163,7 @@ SELECT @time AS '@time', @smalldatetime AS '@smalldatetime';
163163

164164
If the conversion is to **datetimeoffset(n)**, the date is set to '1900-01-01', and the time is copied. The time zone offset is set to +00:00. When the fractional seconds precision of the **time(n)** value is greater than the precision of the **datetimeoffset(n)** value, the value is rounded up to fit. The following example shows the results of converting a `time(4)` value to a `datetimeoffset(3)` type.
165165

166-
```
166+
```sql
167167
DECLARE @time time(4) = '12:15:04.1237';
168168
DECLARE @datetimeoffset datetimeoffset(3) = @time;
169169

@@ -180,7 +180,7 @@ SELECT @time AS '@time', @datetimeoffset AS '@datetimeoffset';
180180

181181
When converting to **datetime2(n)**, the date is set to '1900-01-01', the time component is copied, and the time zone offset is set to 00:00. When the fractional seconds precision of the **datetime2(n)** value is greater than the **time(n)** value, the value will be rounded up to fit. The following example shows the results of converting a `time(4)` value to a `datetime2(2)` value.
182182

183-
```
183+
```sql
184184
DECLARE @time time(4) = '12:15:04.1237';
185185
DECLARE @datetime2 datetime2(3) = @time;
186186

@@ -215,7 +215,7 @@ SELECT @datetime2 AS '@datetime2', @time AS '@time';
215215
### A. Comparing date and time Data Types
216216
The following example compares the results of casting a string to each **date** and **time** data type.
217217

218-
```
218+
```sql
219219
SELECT
220220
CAST('2007-05-08 12:35:29. 1234567 +12:15' AS time(7)) AS 'time'
221221
,CAST('2007-05-08 12:35:29. 1234567 +12:15' AS date) AS 'date'

0 commit comments

Comments
 (0)