I have datetime field where I need to convert to int.
I tried using convert(int,filed) ,but getting below error.
Please help
Below is my date filed: (You can copy and run it)
declare @string varchar(200) = 'Name - Koteswararao vp Department - Prod Location - Hyderabad Domain - ND Job Title - Technical-ABAP Date of Hire - 2021-07-05 Vendor ID - v2345 Candidate ID - Associate ID - 3334 Name - Hardware Allocation';
select dateadd(hour,14,cast(substring(@string, PATINDEX('%20[0-9][0-9]-[0-1][0-9]-[0-3][0-9]%', @string), 10) as datetime))
Error :
Msg 245, Level 16, State 1, Line 3
Conversion failed when converting the varchar value '2021-07-05' to data type int.
