![]() |
To get the current date in T-SQL use the GETDATE() function. The result of the function is DateTime data type meaning, it contains both the date and the time, e.g. 2022-07-10 10:32:04. However, to get the current date without time in T-SQL use the CAST() function. This function takes any expression or any column name as the first argument. Then you use the keyword AS and enter the new data type to return. (The returned value(s) could be column values or the result returned by the expression.) SyntaxSyntax to get the current date without time in T-SQL is:
We’ll use the GETDATE() function to get the current date and time. Then we’ll use the CAST() function to convert the returned DateTime data type into a date data type. SELECT the Current Date Without Time in T-SQL ExampleLet’s look at an example on how to select the current date without time in T-SQL. First, we will create a demo database to run the query. CREATE DATABASE GeeksForGeeks; Query: SELECT CAST( GETDATE() AS Date ) ![]() Get the Current Date Without Time in T-SQL |
Reffered: https://www.geeksforgeeks.org
SQL |
Related |
---|
![]() |
![]() |
|
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 11 |