Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
384 views
in Technique[技术] by (71.8m points)

sql server - SQL convert 'DDMMYY' to datetime

I am trying to convert a date from DDMMYY format to datetime in SQL Server.

I am using the convert command as follows

select convert (datetime, '311012', <style>)

I have tried looking on msdn for the supported styles but haven't found an exact match.

Help will be much appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
select convert (datetime,  Stuff(Stuff('311012',5,0,'.'),3,0,'.'), 4)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...