用列名替换getdate

时间:2014-01-08 09:29:40

标签: sql-server sql-server-2008

select convert(date,GETDATE()) as [date], 
convert(varchar(8), convert(time, '2013-06-03 00:00:00.000')) as [Time]

我想分开获取日期和时间,并使用上述方法。

我正在尝试用表列名替换getdate():

select convert(date,dbo.tbltimetable.AppDate) as [date], 
convert(varchar(8), convert(time, dbo.tbltimetable.AppDate)) as [Time]

这似乎没有帮助:我收到一条错误,说“无法绑定多个标识符” 我哪里出错了。请帮忙。

2 个答案:

答案 0 :(得分:1)

您遗失FROM <TableName> 尝试:

select convert(date,AppDate) as [date], 
  convert(varchar(8), convert(time,AppDate)) as [Time]
FROM dbo.tbltimetable

答案 1 :(得分:1)

试试这个,

select convert(date,tbltimetable.AppDate) as [date], 
convert(varchar(8), convert(time, tbltimetable.AppDate)) as [Time]
from tbltimetable