SELECT communication.*
,employeedetails.resourcename
FROM communication
,employeedetails
WHERE employeedetails.employeenumber = communication.employeenumber
AND communication.project = employeedetails.projectname
ORDER BY
CONVERT(DATETIME ,communication.month ,5)
我收到以下错误消息:
“从字符转换日期和/或时间时转换失败 字符串“
请帮助我
答案 0 :(得分:-1)
关于所涉及的数据表没有任何信息并不容易! 但是,如果名称有意义,您如何将月份转换为日期时间? 如果它存在,试试这个:
SELECT communication.*, employeedetails.resourcename
FROM communication, employeedetails
WHERE employeedetails.employeenumber = communication.employeenumber and communication.project = employeedetails.projectname
ORDER BY communication.day, communication.month, communication.year --due to style 5
即使我建议去寻找风格12
答案 1 :(得分:-1)
communication.month的数据类型可能是字符类型。如果这持有" 1月"对于1月等,那么SQL无法将该字符转换为日期时间。您需要附加一个字符串,以便SQL可以将其解析为日期时间
例如ORDER BY CONVERT(datetime,communication.month + '01 2000',5)
。
但是,首先将通讯日期存储为日期时间会更好......