How do I convert varchar into date in MS sql Server.?
eg - there is a number like this --> 19690409. This is of type varchar. It has to converted into a date format like 1969-04-09(yyyy-mm-dd). After converting how do I subtract this date from 2015-07-01(yyyy-mm-dd).
Please help
You could try to use the convert() and the datediff() functions as below:
select convert(date, '19690409') -- the date you need
select datediff(day, convert(date, '19690409'), '2015-07-01') as diff_in_days
The difference between those two dates is in days, but you can chose from many possible options as stated in the documentation.