需要帮助将 Sybase 中的字符串转换为日期格式
我正在尝试将两种类型的字符串转换为日期格式,但是无法执行其中任何一个。
有问题的输入字符串和预期输出如下:
输入 1: 20100614191522
预期输出 1: 6/14/2010 7:15:22 PM
输入 2: 2010/12
预期输出 2: 12/1/2010 12:00:00 AM
我尝试过,
select convert(datetime,'20100614191522',109)
我尝试使用“转换”功能使用不同的样式参数。但我总是收到以下错误。 将 VARCHAR 值“20100614191522”显式转换为 DATETIME 字段期间出现语法错误。 Msg: 249,Level: 16,State: 1
你能帮我一下,如何实现同样的效果吗?
提前致谢。
I am trying to convert two types of string into date format, however not able to do either of them.
The problematic input strings with expected output are as follows:
Input 1: 20100614191522
Expected output 1: 6/14/2010 7:15:22 PM
Input 2: 2010/12
Expected output 2: 12/1/2010 12:00:00 AM
I tried like ,
select convert(datetime,'20100614191522',109)
I tried with different style parameters with "convert" function . But I always get following errors.
Syntax error during explicit conversion of VARCHAR value '20100614191522' to a DATETIME field.
Msg: 249, Level: 16, State: 1
Can you please help me out, how to achieve the same.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试过的样式参数用于将日期时间数据转换为字符类型。这里你要求相反的转换。
输入 1
给出
输入 2
给出
The style parameters that you have tried is for converting
datetime data
to a character type. Here you are asking for the opposite convertion.Input 1
gives
Input 2
gives