Reference > Functions > Date and Time

GetUtcDate

  • 2005, 2008, 2012, 2014, 2016, 2017, 2019, 2022

GetUtcDate Date and Time Function

Use the GetUtcDate function to return the server's current timestamp as a DateTime value in UTC format (no timezone offset).

Microsoft SQL Server does not require a FROM clause to execute the GetDate function, but dbExpression requires a FROM clause to execute any query. For this function to execute on it's own, a "dummy" FROM clause must be provided.

Syntax

db.fx.GetUtcDate()

Arguments

(none)

Returns

DateTime

Examples

Select Statement

Select the server's current date and time.

DateTime current = db.SelectOne(
        db.fx.GetUtcDate()
    )
    .From(dbo.Purchase) // <- "dummy" from clause
    .Execute();
Previous
GetDate

© 2024 dbExpression. All rights reserved.