SQLforGeeks
  • Home
  • SQL
  • SQL Tutorial
  • SQL Syntax
  • Our Services
Contact
  1. SQL
  2. GETDATE function

Text copied!

« Previous
Next »

GETDATE function

June 9, 2023, 7:10 p.m. under SQL

  • Hi! You should check CASE statement post first.

    In SQL, GETDATE function is used to return the current system date and time in default format of the SQL Server instance.

    The syntax of the GETDATE function generally looks like this :
    GETDATE( )

    • It is a zero parameter function that means it doesn't accept any argument.

    Here's an example of how you might use the GETDATE function :

    1. Let's assume we have a table named "[Employees]".

    GETDATE function

    2. Let's assume you want to append a new column called [CurrentDateTime] to the [Employees] table, containing the current date and time.

    3. Run below SQL statement :

    SELECT *, GETDATE() AS CurrentDateTime
    FROM [Employees];
            

    4. In above statement, GETDATE function retrieves the current date and time and display it as the result in a column named 'CurrentDateTime'.

    GETDATE function
    Remember :

    Using this function in a select statement won't modify the [Employees] table directly, but it will only be reflected in the select statement's output.

    To enhance your understanding of 'SQL functions', be sure to check out our next tutorial.

    Frequently Asked Questions :

    How to use Getdate () function in SQL?

    Use the GETDATE() function in SQL by calling it in your query or statement.

    What datatype is Getdate ()?

    The GETDATE() function returns a datetime datatype.

    How to get todays date in SQL?

    Retrieve today's date in SQL by simply calling the GETDATE() function.

    What is the format of Getdate?

    The format of the GETDATE() function's output is typically in the format: YYYY-MM-DD HH:MM:SS.
    Thank You! You should check DATEPART function post next.
    « Previous
    Next »
    RELATED :

    What is SQL

    What is T-SQL

    Difference between DBMS and Data Warehouse

    Download SQL Server

    Install SQL Server

    Download SQL Server Management Studio SSMS

    SQL Server Management Studio

    SQL Database

    Download database

    Restore database

    Backup database

    Attach database

    Detach database

    Create database

    Delete database

    Rename database

    Select database

    Database offline

    Database online

    SQL Commands

    SQL Tables

    Create table

    Truncate table

    Delete table

    Rename table

    Select table

    Alter table

    SQL Data Types

    SQL Comments

    SQL Constraints

    SQL Joins

    SQL inner join

    SQL left join

    SQL right join

    SQL full join

    SQL cross join

    SQL self join

    INSERT INTO SELECT statement

    INSERT INTO statement

    SQL Clauses

    SELECT clause

    FROM clause

    WHERE clause

    GROUP BY clause

    HAVING clause

    ORDER BY clause

    JOIN clause

    UNION clause

    UNION ALL clause

    TOP clause

    DISTINCT clause

    SQL Operators

    SQL Arithmetic operators

    SQL Comparison operators

    SQL Logical operators

    UNION operator

    UNION ALL operator

    INTERSECT operator

    EXCEPT operator

    LIKE operator

    NOT LIKE operator

    IN operator

    NOT IN operator

    IS NULL operator

    IS NOT NULL operator

    EXISTS operator

    NOT EXISTS operator

    BETWEEN operator

    NOT BETWEEN operator

    SQL Functions

    SQL Built-In functions

    CHARINDEX function

    DATEADD function

    CONCAT function

    LEN function

    REPLACE function

    SUBSTRING function

    CASE statement

    DATEPART function

    DATEDIFF function

    CAST function

    TRY_CAST function

    CONVERT function

    TRY_CONVERT function

    ISNULL function

    NULLIF function

    COALESCE function

    SQL Window functions

    ROW_NUMBER function

    RANK function

    DENSE_RANK function

    IIF function

    CHOOSE function

    SQL Store Procedure

    Store Procedure vs. Function

    SQL Subquery

    SQL Aliases

    Temp table

    SQL Error Handling

    SQL Variables

    SQL Views

    SQL Merge

    SQL CTE

    SQL WITH TIES

    Define Transaction in DBMS

    ACID properties in DBMS

    Types of Triggers in DBMS


    • Have Some Questions?
    logo

    Elevate your data experience with SQL excellence

    Quick Links
    •  Home
    •  SQL Tutorial
    •  SQL Syntax
    •  Our Services
    Our Services
    • Web Development
    • BI Development
    • Data Warehousing
    • Data Integration ETL


    Follow Us

    GST Registered: XXAXXXXXXXZX
    Mumbai, Maharashtra, India

    © 2024 Copyright | All Rights Reserved | Privacy Policy