转换 Select 语句中的参数
我正在尝试在我的 select 语句中转换日期参数,但我想对其进行格式化,但目前它不接受我的编写方式 - 任何建议将不胜感激
SELECT @cases = COALESCE(@cases+ @linebreak + C.CaseNumber, C.CaseNumber)+"-"+CT.[Description]+"-"+CONVERT(VARCHAR,@assignment,100)AS A.DateOn
这就是我在格式化之前的方式,它正在转换和工作正常:
SELECT @cases = COALESCE(@cases+ @linebreak + C.CaseNumber, C.CaseNumber)+"-"+CT.[Description]+"-"+CONVERT(VARCHAR, A.DateOn)
不确定是否需要更多信息,但请告诉我。
I am trying to convert a date parameter in my select statement but i wanted to format it and currently it is not accepting how i have it written -- Any advice would be appreciated
SELECT @cases = COALESCE(@cases+ @linebreak + C.CaseNumber, C.CaseNumber)+"-"+CT.[Description]+"-"+CONVERT(VARCHAR,@assignment,100)AS A.DateOn
This is how i had it before the formatting and it was converting and working fine:
SELECT @cases = COALESCE(@cases+ @linebreak + C.CaseNumber, C.CaseNumber)+"-"+CT.[Description]+"-"+CONVERT(VARCHAR, A.DateOn)
Not sure if more information will be needed or not but let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
猜测,你的最后一点应该是
@assignment 来自哪里?您的未格式化代码没有提及它...
注意(问题评论后)4/14/2010 比 04/14/2010 更难做到。您必须分别评估日、月和年以删除前导零
Guessing, your last bit should be
Where does @assignment come from? Your unformatted code doesn't mention it...
Note (after question comment) 4/14/2010 is harder to do than 04/14/2010. You have to evaluate day, month and year separately to remove leading zeros