Majid
Majid

Reputation: 664

SQL Datetime: add time on Oracle and SQL Server

Having database servers on both SQL Server and Oracle Server,

I couldn't find any homogeneous answer for adding time to a date.

What I would do on SQL Server:

select dateadd(minute, 1, CreationDate) from comments

and on Oracle Server (even though this isn't a pretty solution):

select CreationDate + (1/1440) from comments

1440 being the minutes in a day.

Is there any solution that would work on both servers?

Upvotes: 2

Views: 263

Answers (1)

user4622594
user4622594

Reputation:

I don't know if this works on Oracle but this works on SQL Server (Tested on 2014 Ex. Edition):

select CreationDate + (1./1440) from comments

The only thing that's different to your oracle solution is the dot behind 1 - just to tell sql server that this is not an integer column but a float.

Upvotes: 1

Related Questions