user1166981 user1166981 - 1 month ago 12
SQL Question

Is there an equivalent in SQL as microtime() for PHP?

I assumed there would be a query you can make in SQL for this, microtime() is derived from the server environment so I hoped there would be a 'like-for-like' in SQL, but I can't see it. Im using MSSQL but would be interested in other dbs too.

Answer

Assuming MySQL, can you try something like this:

SELECT UNIX_TIMESTAMP();

Here is the SQL Fiddle which also shows the use of MySQLs MicroSecond method.

--EDIT

Since you're using SQL Server, can this work:

SELECT SYSDATETIME()

And the SQL Fiddle.

Comments