Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the common sql for sysdate and getdate()

I need to use sysdate in both Oracle and SQL Server, but SQL Server has a GETDATE() function instead.

But I don't want to create 2 separate queries

Is there any specific common syntax which gives same output to sysdate and getdate in SQL Server and oracle

like image 877
Akshat Avatar asked Oct 19 '12 16:10

Akshat


2 Answers

CURRENT_TIMESTAMP is valid syntax for both SQL Server and Oracle. Oracle will return the current date and time in the session time zone. SQL Server will return the current date and time of the Operating System

like image 157
Pete Carter Avatar answered Oct 13 '22 05:10

Pete Carter


You could also just alias it in t-sql to match Oracle's function?

CREATE FUNCTION sysdate ()
RETURNS DATETIME
AS
BEGIN
    RETURN getdate()
END
GO
like image 35
Oxydel Avatar answered Oct 13 '22 05:10

Oxydel