Forum Discussion
Msg 241, Level 16, State 1, Line 1 Conversion failed when converting date and/or time from character
- 5 years ago
Hi LisaRoby ,
Change (trlr.dispatch_dte > convert(datetime, '7/29/2020 00:00:00', 126)) to the below:
trlr.dispatch_dte>=cast('2020-07-29' as date)1. SELECT * FROM [master].[dbo].[trlr];
2. SELECT * FROM [master].[dbo].[trlr] where (trlr.dispatch_dte > convert(datetime, '7/29/2020 00:00:00', 126));
the same error as your's.
3. SELECT *FROM [master].[dbo].[trlr] where trlr.dispatch_dte>=cast('2020-07-29' as date);
successful.
Don't forget to give thumbs up and accept this as a solution if it helped you!!!
Best Regards
Lucien
Hi LisaRoby ,
Change (trlr.dispatch_dte > convert(datetime, '7/29/2020 00:00:00', 126)) to the below:
trlr.dispatch_dte>=cast('2020-07-29' as date)
1. SELECT * FROM [master].[dbo].[trlr];
2. SELECT * FROM [master].[dbo].[trlr] where (trlr.dispatch_dte > convert(datetime, '7/29/2020 00:00:00', 126));
the same error as your's.
3. SELECT *FROM [master].[dbo].[trlr] where trlr.dispatch_dte>=cast('2020-07-29' as date);
successful.
Don't forget to give thumbs up and accept this as a solution if it helped you!!!
Best Regards
Lucien
Thank you for your response, however, I took that date field out of the query and I still got that error. The strange part about it is I had another sql similar to this one and the others I was trying to convert, has exactly the same date fields ets. and it ran, so I am using it. I appreciate the time you took to help.
Lisa