How do I get current system time in SQL Server?
如何在SQL Server中获取当前系统时间?
4 个解决方案
#2
7
CURRENT_TIMESTAMP is ANSI compliant and equivalent to GETDATE()
CURRENT_TIMESTAMP是符合ANSI的,相当于GETDATE()
Otherwise, you have a plethora of functions as mentioned in SQL Server 2008 BOL here (with link for SQL Server 2005 too).
否则,您就会在SQL Server 2008 BOL中有过多的功能(也有SQL Server 2005的链接)。
I think marc_s might have missed 1 or 2 ;-)
我想marc_s可能漏掉了1或2;-)
#3
6
Since SQL Server 2000, we also had:
从SQL Server 2000开始,我们还有:
-
GETUTCDATE()
to get the UTC (Universal Time) - no dependant on local time zone settings - GETUTCDATE()获取UTC(通用时间)——不依赖于本地时区设置
SQL Server 2008 (the OP didn't specify his exact version) also has:
SQL Server 2008 (OP没有指定他的确切版本)也有:
-
SYSDATETIMEOFFSET()
to get the current local time including the timezone offset as DATETIMEOFFSET data type (new to SQL Server 2008) - SYSDATETIMEOFFSET()获取当前本地时间,包括时区偏移量作为DATETIMEOFFSET数据类型(SQL Server 2008的新版本)
SQL Server 2008 also offers SYSDATETIME()
and SYSUTCDATETIME()
with more accuracy (down to 100ns) than GETDATE()
or GETUTCDATE()
in previous versions (accuracy: 3.33ms).
SQL Server 2008还提供了SYSDATETIME()和SYSUTCDATETIME()(),精度比以前版本中的GETDATE()或GETUTCDATE()更高(精度为3.33ms)。
#4
0
dater datetime default getupdate() dater it is an name of column datetime it is an datatype default it is an assign current system date and time
dater datetime默认getupdate() dater是列datetime的名称,它是一个datatype默认值,它是一个指定的当前系统日期和时间。
but the inserting a column data we firstly mention the column names i.e. insert into table_name(column names) values(that mention in column names);
但是插入一个列数据时,我们首先提到列名称,即插入到table_name(列名称)值(在列名中提到);
#1
#2
7
CURRENT_TIMESTAMP is ANSI compliant and equivalent to GETDATE()
CURRENT_TIMESTAMP是符合ANSI的,相当于GETDATE()
Otherwise, you have a plethora of functions as mentioned in SQL Server 2008 BOL here (with link for SQL Server 2005 too).
否则,您就会在SQL Server 2008 BOL中有过多的功能(也有SQL Server 2005的链接)。
I think marc_s might have missed 1 or 2 ;-)
我想marc_s可能漏掉了1或2;-)
#3
6
Since SQL Server 2000, we also had:
从SQL Server 2000开始,我们还有:
-
GETUTCDATE()
to get the UTC (Universal Time) - no dependant on local time zone settings - GETUTCDATE()获取UTC(通用时间)——不依赖于本地时区设置
SQL Server 2008 (the OP didn't specify his exact version) also has:
SQL Server 2008 (OP没有指定他的确切版本)也有:
-
SYSDATETIMEOFFSET()
to get the current local time including the timezone offset as DATETIMEOFFSET data type (new to SQL Server 2008) - SYSDATETIMEOFFSET()获取当前本地时间,包括时区偏移量作为DATETIMEOFFSET数据类型(SQL Server 2008的新版本)
SQL Server 2008 also offers SYSDATETIME()
and SYSUTCDATETIME()
with more accuracy (down to 100ns) than GETDATE()
or GETUTCDATE()
in previous versions (accuracy: 3.33ms).
SQL Server 2008还提供了SYSDATETIME()和SYSUTCDATETIME()(),精度比以前版本中的GETDATE()或GETUTCDATE()更高(精度为3.33ms)。
#4
0
dater datetime default getupdate() dater it is an name of column datetime it is an datatype default it is an assign current system date and time
dater datetime默认getupdate() dater是列datetime的名称,它是一个datatype默认值,它是一个指定的当前系统日期和时间。
but the inserting a column data we firstly mention the column names i.e. insert into table_name(column names) values(that mention in column names);
但是插入一个列数据时,我们首先提到列名称,即插入到table_name(列名称)值(在列名中提到);