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.
2101 次
3 に答える
3
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.
于 2013-01-12T03:25:37.640 に答える
0
select cast(datediff(second,'19700101',CURRENT_TIMESTAMP) as varchar)
+'.'+ cast(DATEPART(microsecond,CURRENT_TIMESTAMP) as varchar)
于 2013-01-12T04:37:48.463 に答える
0
As of MYSQL 5.6.4 to emulate microtime()
you can use
select concat(mod(unix_timestamp(now(6)),1),'00 ',unix_timestamp());
and to emulate microtime(true)
select concat(unix_timestamp(now(6)),'00');
The '00
' on both queries is there because MYSQL has a precision of only 6 digits. More info on https://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_now
于 2016-10-24T15:22:42.717 に答える