i have a date field with type varchar. now i want to get time difference in days with today's date how can i get it?
actually i want to get rows which have day difference of more than 30 days.I have a field of lastlogin,i want to compare lastlogin with today's datetime and if the difference is more than 30 days we want to send those persons emails.
Loading

Shankar MRank #874 · 2.5K reputationPosted Nov 26, 2012, 10:31 PM EST
Hi User,
Convert the varchar datatype to date and try comparing using the DATEDIFF function.
Something like this,
select datediff(d,getdate(),getdate()); will get you the Difference in days.
Thanks,
Shankar
Muhammad younas164 reputationPosted Nov 26, 2012, 10:51 PM EST
Shankar MRank #874 · 2.5K reputationPosted Nov 26, 2012, 11:00 PM EST
Yes, You can use the cast to convert it to DATE type.
Hope the below link might help you.
http://sqlusa.com/bestpractices2005/sqlserverstringtodate/
Thanks,
Shankar
sathish kumar115 reputationPosted Jan 2, 2013, 8:23 PM EST
DateTime EndDate= convert.Todatetime(txtbox2.text).tostring();
TimeSpan ts;
ts= startDate- EndDate
int s = ts.Todays();
Hope this will help u out......
Neha SharmaRank #569 · 4.3K reputationPosted Jan 2, 2013, 9:25 PM EST
may be it ll help you and l give you some ideas to get the desired result:
http://stackoverflow.com/questions/2821040/how-do-i-find-the-time-difference-between-two-datetime-objects-in-asp-net
if not then please let me know.
Thanks.