如何仅在SQL Server / any数据库中获取当前系统时间。
日期不是required...only,当前时间是必需的。
发布于 2012-11-23 19:07:10
您可以使用getdate()或current_timestamp
这将为您提供日期和时间,但您可以根据需要对其进行格式化。
如果您使用的是SQL Server 2008+,您甚至可以将结果格式化为time
select cast(getdate() as time)如果您不在SQL Server 2008+中,那么您可以使用许多different methods来获取时间,包括:
SELECT convert(char(8), getdate(), 108)请参阅具有多个版本的SQL fiddle demo
发布于 2012-11-23 19:06:28
Using `getdate()` like:
select getdate()
=============================
and get only time use convert function with 108 code like :
select convert(varchar,GETDATE(),108)发布于 2012-11-23 19:31:06
select CONVERT(VARCHAR(8),GETDATE(),108) CurrTime;
https://stackoverflow.com/questions/13527789
复制相似问题