English 中文(简体)
无法在 SQL 服务器中将 varchar 转换为约会时间
原标题:could not convert varchar to datetime in SQL server
  • 时间:2012-05-28 07:00:50
  •  标签:
  • sql-server

在我的数据库里,我把vachar转换为约会时间时遇到了问题,因为日期日期格式不同,如下文所示。

Conversion failed when converting date and/or time from character string.

我下面有2个选择条款

Select Getutcdate()
Select top 1 localmachinetime from perfmon

分别按格式返回

2012-05-28 06:54:45.753>

28-005-2012 03:03:03:07

当我试图用CAST将其转换为约会时间时, 它会让我在下面的第二个案例中出错 。

The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

最佳回答

您可以使用 < a href=> http://msdn.microsoft.com/ en- us/library/ms 187928.aspx?ppud=4" rel="nofollow"\\code> 转换 和 Date/Time 风格。

convert(datetime,  28-05-2012 03:03:07 , 105)
问题回答

暂无回答




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签