jingamells Posted August 19, 2020 Share Posted August 19, 2020 Hi, I am using the below to try and change a string of dd/mm/yy hh:mm to yyyymmdd and getting the following error: 'Conversion failed when converting date and/or time from character string.' convert(varchar(8),cast(ArrivalDateTime as date),112) as ArrivalDateTime, what am i doing wrong? TIA James Link to comment Share on other sites More sharing options...
Sherin Posted September 10, 2020 Share Posted September 10, 2020 (edited) insert into table1 values('2012-02-21T18:10:00', '2012-01-01T00:00:00'); SELECT CAST('02-21-2012 6:10:00 PM' AS DATETIME2), CAST('01-01-2012 12:00:00 AM' AS DATETIME2) You can try this. Edited September 10, 2020 by Sherin Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now