Shiva Krishna Bavandla
Shiva Krishna Bavandla

Reputation: 26728

How to convert a query from Mssql in to a query in Msql

Hi I worked on Mssql recently and somewhere i got following query

query = "select dateadd(SS,1,getdate()) as 'StartTime'"

Here i can expect getdate() in Mssql is now() in Mysql

But i want to do the functionality of the above MSSQL query in MYSQL , so can anyone please let me know how to write the same query in MYSQL

Upvotes: 0

Views: 107

Answers (4)

Himanshu
Himanshu

Reputation: 32602

query = "SELECT DATE_ADD(now(), INTERVAL 1 SECOND) as StartTime"

See the SQLFiddle

Reference MySQL: DATE_ADD

Upvotes: 1

John Woo
John Woo

Reputation: 263803

Try this,

query = "SELECT DATE_ADD(NOW, INTERVAL 1 SECOND) `Start_Time`"

DATE_ADD

Upvotes: 0

user254875486
user254875486

Reputation: 11240

You can use this:

SELECT DATE_ADD(NOW(), INTERVAL 1 SECOND) AS starttime

Upvotes: 0

shahkalpesh
shahkalpesh

Reputation: 33474

DATE_ADD(now(), 1, 'SECONDS')

Based on documentation here

OR

now() + INTERVAL 1 SECOND

Upvotes: 2

Related Questions