id
stringlengths
16
145
text
stringlengths
1
179k
title
stringclasses
1 value
U_SQL_cross_apply/dateandtimedatatypes_43_0.txt
Article | Description ---|--- [ FORMAT ](format-transact-sql?view=sql-server-ver16) | Returns a value formatted with the specified format and optional culture. Use the FORMAT function for locale-aware formatting of date/time and number values as strings. [ CAST and CONVERT (Transact-SQL) ](cast-and-convert-transact-...
U_SQL_cross_apply/differentsqltimestam_72_0.txt
**weekday, dw**
U_SQL_cross_apply/dateandtimedatatypes_39_0.txt
Function | Syntax | Return value | Return data type | Determinism ---|---|---|---|--- [ @@DATEFIRST ](datefirst-transact-sql?view=sql-server-ver16) | @@DATEFIRST | Returns the current value, for the session, of SET DATEFIRST. | **tinyint** | Nondeterministic [ SET DATEFIRST ](../statements/set-datefirst-tra...
U_SQL_cross_apply/differentsqltimestam_279_0.txt
[ Database development ](https://www.sqlshack.com/category/sql-database- development/) , [ SQL commands ](https://www.sqlshack.com/category/languages- and-coding/sql-commands/)
U_SQL_cross_apply/differentsqltimestam_64_0.txt
June
U_SQL_cross_apply/currenttimestamptran_40_0.txt
/* Returned SYSDATETIME() 13:18:45.3490361 SYSDATETIMEOFFSET()13:18:45.3490361 SYSUTCDATETIME() 20:18:45.3490361 CURRENT_TIMESTAMP 13:18:45.3470000 GETDATE() 13:18:45.3470000 GETUTCDATE() 20:18:45.3470000 */
U_SQL_cross_apply/differentsqltimestam_172_0.txt
SELECT TIMEFROMPARTS ( 22 , 59 , 59 , 5 , 1 ) as fp1 ,
U_SQL_cross_apply/devenvsqltimestamppr_22_0.txt
Each table includes a hidden timestamp field. The timestamp field contains row version numbers for records as maintained in SQL Server. This property exposes the timestamp field in the table object, and enables you to write code against it. This property only applies to fields that have the data type ` BigInteger ` . F...
U_SQL_cross_apply/cross_apply_1_5.txt
} } }; **IEnumerable <T> \- Additional Example, Part 2 ** Example is meant to be executed _locally_ . Using [ Code-Behind ](/en- us/azure/data-lake-analytics/data-lake-analytics-u-sql-programmability- guide#using-code-behind-1) from previous section, **above** . // The Director...
U_SQL_cross_apply/dateandtimedatatypes_10_0.txt
* Article * 03/03/2023 * 18 contributors
U_SQL_cross_apply/differentsqltimestam_148_0.txt
Query: **SELECT DATETIMEFROMPARTS ( 2022, 06, 26, 11, 01, 59, 0 ) AS Result;**
U_SQL_cross_apply/differentsqltimestam_266_0.txt
[ ](https://twitter.com/rajendragupta16 "Twitter")
U_SQL_cross_apply/differentsqltimestam_11_0.txt
Data Type
U_SQL_cross_apply/differentsqltimestam_240_0.txt
SELECT SWITCHOFFSET ( GETDATE ( ) , \- 5 ) AS 'Result' ;
U_SQL_cross_apply/differentsqltimestam_68_0.txt
**day, dd, d**
U_SQL_cross_apply/dateandtimedatatypes_21_0.txt
## Date and time functions
U_SQL_cross_apply/currenttimestamptran_12_0.txt
## In this article
U_SQL_cross_apply/currenttimestamptran_23_0.txt
To view Transact-SQL syntax for SQL Server 2014 (12.x) and earlier versions, see [ Previous versions documentation ](../../sql-server/previous-versions- sql-server?view=sql-server-ver16#offline-documentation) .
U_SQL_cross_apply/dateandtimedatatypes_0_0.txt
Skip to main content
U_SQL_cross_apply/differentsqltimestam_17_0.txt
* The Date data type can store values from 0001-01-01 through 9999-12-31. * It uses 3 bytes of storage with an accuracy of 1 day.
U_SQL_cross_apply/U_SQL_3_0.txt
Skip to main content This browser is no longer supported. Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. [ Download Microsoft Edge ](https://go.microsoft.com/fwlink/p/?LinkID=2092881 ) [ More info about Internet Explorer and Microsoft Edge ](https://learn...
U_SQL_cross_apply/U_SQL_1_0.txt
Skip to main content This browser is no longer supported. Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. [ Download Microsoft Edge ](https://go.microsoft.com/fwlink/p/?LinkID=2092881 ) [ More info about Internet Explorer and Microsoft Edge ](https://learn...
U_SQL_cross_apply/differentsqltimestam_263_0.txt
This article explored the various SQL TimeStamp functions along with examples. You can use these functions to work with date time values in SQL Server and extract a relevant part from the timestamp.
U_SQL_cross_apply/differentsqltimestam_295_0.txt
* [ Read a SQL Server transaction log ](https://solutioncenter.apexsql.com/read-a-sql-server-transaction-log/) * [ SQL Server database auditing techniques ](https://solutioncenter.apexsql.com/sql-server-database-auditing-techniques/) * [ How to recover SQL Server data from accidental UPDATE and DELETE operations ](http...
U_SQL_cross_apply/differentsqltimestam_105_0.txt
**day, dd, d**
U_SQL_cross_apply/differentsqltimestam_176_0.txt
![TIMEFORMATS function](data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==) ![TIMEFORMATS function](https://s33046.pcdn.co/wp- content/uploads/2022/11/timeformats-function.png)
U_SQL_cross_apply/differentsqltimestam_288_0.txt
### Popular
U_SQL_cross_apply/differentsqltimestam_188_0.txt
DATEDIFF ( minute , '2022-06-26 00:00:00.0000000' , '2022-06-26 23:59:59.9999999' ) as 'minute' ,
U_SQL_cross_apply/currenttimestamptran_7_0.txt
Twitter LinkedIn Facebook Email
U_SQL_cross_apply/devenvsqltimestamppr_40_0.txt
* * [ Previous Versions ](/en-us/previous-versions/) * [ Blog ](https://techcommunity.microsoft.com/t5/microsoft-learn-blog/bg-p/MicrosoftLearnBlog) * [ Contribute ](/en-us/contribute/) * [ Privacy ](https://go.microsoft.com/fwlink/?LinkId=521839) * [ Terms of Use ](/en-us/legal/termsofuse) * [ Trademarks ](https://w...
U_SQL_cross_apply/devenvsqltimestamppr_44_0.txt
Theme
U_SQL_cross_apply/dateandtimedatatypes_60_0.txt
Theme
U_SQL_cross_apply/differentsqltimestam_144_0.txt
* A fractions value of 500 and a precision value of 3 represents 500/1000 of a second.
U_SQL_cross_apply/differentsqltimestam_126_0.txt
**ISO_WEEK, ISOWK, ISOWW**
U_SQL_cross_apply/differentsqltimestam_252_0.txt
ELSE
U_SQL_cross_apply/U_SQL_0_1.txt
-from-an-external-rowset) | [Pivot_Expression](from/pivot-and-unpivot) | [Unpivot_Expression](from/pivot-and-unpivot). * **` Table_Value_Constructor ` ** U-SQL’s SELECT can also select from the [ VALUES table value constructor ](from/select-selecting-from-the-values-table-value-construct...
U_SQL_cross_apply/differentsqltimestam_221_0.txt
UNION ALL
U_SQL_cross_apply/differentsqltimestam_40_0.txt
* SYSDATETIME() * * The SYSDATETIME() function gives the date and time of the SQL Server machine. * It uses **datetime2(7)** data type output value. * Query: **SELECT SYSDATETIME() AS ‘DateAndTime’;** output 2022-06-26 15:51:18.6207415 * SYSDATETIMEOFFSET() * * The SYSDATETIMEOFFSET() gives the date and tim...
U_SQL_cross_apply/differentsqltimestam_242_0.txt
![SWITCHOFFSET function](data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==) ![SWITCHOFFSET function](https://s33046.pcdn.co/wp- content/uploads/2022/11/switchoffset-function.png)
U_SQL_cross_apply/differentsqltimestam_257_0.txt
SELECT 'VALID' ;
U_SQL_cross_apply/cross_apply_2_3.txt
(x); @ca_val2 = SELECT * FROM @bands CROSS APPLY VALUES (1),(name.Length) AS T(x); @ca_val3 = SELECT * FROM @bands CROSS APPLY VALUES (1,name.Length,3) AS T(x,y,z); OUTPUT @ca_val1 TO "/output/ReferenceGuide/DML/Appplier/crossapply_value1.csv" USING Outputters.Csv(); OUTPUT @ca_val2 ...
U_SQL_cross_apply/differentsqltimestam_79_0.txt
**second, ss, s**
U_SQL_cross_apply/differentsqltimestam_151_0.txt
Query: **SELECT DATETIMEOFFSETFROMPARTS ( 2022, 06, 26, 15, 14, 23, 0, 12, 0, 7 ) AS Result;**
U_SQL_cross_apply/differentsqltimestam_65_0.txt
**dayofyear, dy, y**
U_SQL_cross_apply/differentsqltimestam_211_0.txt
UNION ALL
U_SQL_cross_apply/currenttimestamptran_36_0.txt
SELECT CONVERT (DATE, SYSDATETIME()) ,CONVERT (DATE, SYSDATETIMEOFFSET()) ,CONVERT (DATE, SYSUTCDATETIME()) ,CONVERT (DATE, CURRENT_TIMESTAMP) ,CONVERT (DATE, GETDATE()) ,CONVERT (DATE, GETUTCDATE());
U_SQL_cross_apply/differentsqltimestam_259_0.txt
SELECT 'INVALID' ;
U_SQL_cross_apply/currenttimestamptran_6_0.txt
Table of contents Read in English Save Add to Plan [ Edit ](https://github.com/MicrosoftDocs/sql- docs/blob/live/docs/t-sql/functions/current-timestamp-transact-sql.md "Edit This Document") Print
U_SQL_cross_apply/differentsqltimestam_85_0.txt
SELECT DATENAME(MICROSECOND, GETDATE()) AS ‘MicroSecond’;
U_SQL_cross_apply/devenvsqltimestamppr_15_0.txt
## Applies to
U_SQL_cross_apply/differentsqltimestam_27_0.txt
DateTime2
U_SQL_cross_apply/differentsqltimestam_250_0.txt
IF ISDATE ( '2022-05-12 10:19:41.177' ) = 1
U_SQL_cross_apply/devenvsqltimestamppr_20_0.txt
SQLTimestamp = true;
U_SQL_cross_apply/differentsqltimestam_287_0.txt
[ ![](https://s33046.pcdn.co/wp-content/uploads/2023/08/MediaBanner- Shareplex-300x250-IM-JY-79545.gif) ](https://www.quest.com/products/shareplex/?utm_source=sql_shack&utm_medium=Direct- Outbound%20Marketing&utm_campaign=FY2024_Q2_AMER_SharePlex_SQLShack_ADV&utm_term=&utm_content=banner)
U_SQL_cross_apply/differentsqltimestam_39_0.txt
#### Higher precision timestamp functions
U_SQL_cross_apply/differentsqltimestam_187_0.txt
DATEDIFF ( hour , '2022-06-26 00:00:00.0000000' , '2022-06-26 23:59:59.9999999' ) as 'hour' ,
U_SQL_cross_apply/currenttimestamptran_9_0.txt
# CURRENT_TIMESTAMP (Transact-SQL)
U_SQL_cross_apply/differentsqltimestam_278_0.txt
1. [ SQL Server Transaction Log Administration Best Practices ](https://www.sqlshack.com/sql-server-transaction-log-administration-best-practices/ "SQL Server Transaction Log Administration Best Practices") 2. [ SQL Restore Database using DBATools ](https://www.sqlshack.com/sql-restore-database-using-dbatools/ "SQL Res...
U_SQL_cross_apply/differentsqltimestam_244_0.txt
SELECT TODATETIMEOFFSET ( SYSDATETIME ( ) , \- 120 ) 'Result1' ,
U_SQL_cross_apply/differentsqltimestam_275_0.txt
Latest posts by Rajendra Gupta ( [ see all ](https://www.sqlshack.com/author/rajendra-gupta/) )
U_SQL_cross_apply/differentsqltimestam_171_0.txt
If we use the fraction and precision value as per the logic specified earlier, the TIMEFROMPARTS function returns the following output:
U_SQL_cross_apply/differentsqltimestam_289_0.txt
* [ SQL Convert Date functions and formats ](https://www.sqlshack.com/sql-convert-date-functions-and-formats/) * [ SQL Variables: Basics and usage ](https://www.sqlshack.com/sql-variables-basics-and-usage/) * [ SQL PARTITION BY Clause overview ](https://www.sqlshack.com/sql-partition-by-clause-overview/) * [ Different ...
U_SQL_cross_apply/differentsqltimestam_100_0.txt
**month, mm, m**
U_SQL_cross_apply/differentsqltimestam_237_0.txt
---|---
U_SQL_cross_apply/currenttimestamptran_10_0.txt
* Article * 04/25/2024 * 15 contributors
U_SQL_cross_apply/dateandtimedatatypes_5_0.txt
Read in English Save [ ](https://github.com/MicrosoftDocs/sql- docs/blob/live/docs/t-sql/functions/date-and-time-data-types-and-functions- transact-sql.md "Edit This Document")
U_SQL_cross_apply/differentsqltimestam_226_0.txt
SELECT 'second' , DATEADD ( second , 1 , @ datetime )
U_SQL_cross_apply/differentsqltimestam_290_0.txt
[ ![](https://s33046.pcdn.co/wp-content/uploads/2023/01/ApexSQL_banner.jpg) ](https://shop.quest.com/682/purl-apexsql?x-adcode=sqlshkbnr )
U_SQL_cross_apply/currenttimestamptran_53_0.txt
Submit and view feedback for
U_SQL_cross_apply/currenttimestamptran_17_0.txt
This function is the ANSI SQL equivalent to [ GETDATE ](getdate-transact- sql?view=sql-server-ver16) .
U_SQL_cross_apply/differentsqltimestam_269_0.txt
I am the author of the book " [ DP-300 Administering Relational Database on Microsoft Azure ](https://store.pothi.com/book/rajendra-gupta-administering- relational-databases-microsoft-azure/) ". I published more than 650 technical articles on MSSQLTips, SQLShack, Quest, CodingSight, and SeveralNines.
U_SQL_cross_apply/dateandtimedatatypes_32_0.txt
### Functions that return date and time values from their parts
U_SQL_cross_apply/currenttimestamptran_54_0.txt
[ This product ](https://feedback.azure.com/d365community/forum/04fe6ee0-3b25-ec11-b6e6-000d3a4f0da0) This page
U_SQL_cross_apply/differentsqltimestam_220_0.txt
SELECT 'weekday' , DATEADD ( weekday , 1 , @ datetime )
U_SQL_cross_apply/differentsqltimestam_218_0.txt
SELECT 'week' , DATEADD ( week , 1 , @ datetime )
U_SQL_cross_apply/differentsqltimestam_271_0.txt
Based on my contribution to the SQL Server community, I have been recognized as the prestigious **Best Author of the Year** continuously in 2019, 2020, and 2021 (2nd Rank) at SQLShack and the MSSQLTIPS champions award in 2020.
U_SQL_cross_apply/differentsqltimestam_137_0.txt
![DATETIME2FROMPARTS function output](data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==) ![DATETIME2FROMPARTS function output](https://s33046.pcdn.co/wp- content/uploads/2022/11/datetime2fromparts-function-output.png)
U_SQL_cross_apply/cross_apply_1_2.txt
e first converts the ` PhoneNumbers ` values into the ` SQL.ARRAY ` type ` AS PhoneNumbersArray ` . ` PhoneNumbersArray ` is then unpacked resulting in a single column where each item in the array is placed into its own row. @array = SELECT EmpName, PhoneNumbers == "" ? null : new ...
U_SQL_cross_apply/devenvsqltimestamppr_38_0.txt
Theme
U_SQL_cross_apply/differentsqltimestam_258_0.txt
ELSE
U_SQL_cross_apply/differentsqltimestam_267_0.txt
[ Rajendra Gupta ](https://www.sqlshack.com/author/rajendra-gupta/)
U_SQL_cross_apply/differentsqltimestam_35_0.txt
* Functions to return system date and time values * Functions to return date and time parts * Functions to return date and time values from their parts * Functions to return date and time difference values * Functions to modify date and time values * Functions to validate date and time values
U_SQL_cross_apply/currenttimestamptran_18_0.txt
See [ Date and Time Data Types and Functions ](date-and-time-data-types-and- functions-transact-sql?view=sql-server-ver16) for an overview of all the Transact-SQL date and time data types and functions.
U_SQL_cross_apply/differentsqltimestam_213_0.txt
UNION ALL
U_SQL_cross_apply/differentsqltimestam_44_0.txt
[ ![Different SQL TimeStamp functions in SQL Server](data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==) ![Different SQL TimeStamp functions in SQL Server](https://s33046.pcdn.co/wp- content/uploads/2022/11/different-sql-timestamp-functions-in-sql-server.png) ](https://s33046.pcdn.co/wp-content/...
U_SQL_cross_apply/devenvsqltimestamppr_34_0.txt
[ View all page feedback ](https://github.com//issues)
U_SQL_cross_apply/devenvsqltimestamppr_17_0.txt
## Property Value
U_SQL_cross_apply/devenvsqltimestamppr_1_0.txt
This browser is no longer supported.
U_SQL_cross_apply/differentsqltimestam_261_0.txt
![ISDATE\(\) function for valid and invalid dates](data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==) ![ISDATE\(\) function for valid and invalid dates](https://s33046.pcdn.co/wp- content/uploads/2022/11/isdate-function-for-valid-and-invalid-dates.png)
U_SQL_cross_apply/dateandtimedatatypes_8_0.txt
Table of contents
U_SQL_cross_apply/differentsqltimestam_36_0.txt
Let’s explore each category related to SQL Server TimeStamp functions.
U_SQL_cross_apply/differentsqltimestam_108_0.txt
SELECT DATEPART(WEEK, GETDATE()) AS ‘Week’;
U_SQL_cross_apply/dateandtimedatatypes_27_0.txt
Function | Syntax | Return value | Return data type | Determinism ---|---|---|---|--- [ SYSDATETIME ](sysdatetime-transact-sql?view=sql-server-ver16) | SYSDATETIME ( ) | Returns a **datetime2(7)** value containing the date and time of the computer on which the instance of SQL Server runs. The returned value ...
U_SQL_cross_apply/dateandtimedatatypes_45_0.txt
* [ Functions ](functions?view=sql-server-ver16) * [ Data Types (Transact-SQL) ](../data-types/data-types-transact-sql?view=sql-server-ver16)
U_SQL_cross_apply/currenttimestamptran_31_0.txt
## Examples
U_SQL_cross_apply/differentsqltimestam_84_0.txt
**microsecond, mcs**
U_SQL_cross_apply/U_SQL_2_1.txt
0, (int?)8000, new DateTime(2014,03,08)), (7, "Jacob", 200, (int?)8000, new DateTime(2014,09,02)), (8, "Olivia", 200, (int?)8000, new DateTime(2013,12,11)), (9, "Mason", 300, (int?)50000, new DateTime(2016,01,01)), (10, "Ava", 400, (int?)15000, new DateTime(2014,09,14)), (11, "Ethan", 400, (i...
U_SQL_cross_apply/differentsqltimestam_69_0.txt
SELECT DATENAME(DAY, GETDATE()) AS ‘Day’;
U_SQL_cross_apply/currenttimestamptran_39_0.txt
SELECT CONVERT (TIME, SYSDATETIME()) ,CONVERT (TIME, SYSDATETIMEOFFSET()) ,CONVERT (TIME, SYSUTCDATETIME()) ,CONVERT (TIME, CURRENT_TIMESTAMP) ,CONVERT (TIME, GETDATE()) ,CONVERT (TIME, GETUTCDATE());
U_SQL_cross_apply/differentsqltimestam_121_0.txt
SELECT DATEPART(MICROSECOND, GETDATE()) AS ‘MicroSecond’;;