C# Number of Days between two dates?

I'm getting an error when I try to get the number of days between today's date and a date stored in linqtosql column. What am I doing wrong?

 Argument '1': cannot convert from 'System.DateTime?' to 'System.DateTime'

int days = DateTime.Now.Subtract(linq.ENTRY_DATE).Day;

0
BellaScout
2/12/2009 3:06:00 AM
📁 asp.net.getting-started
📃 91979 articles.
⭐ 3 followers.

💬 2 Replies
👁️‍🗨️ 981 Views

you need to get the datetime value from the nullable datetime.

try it like this:

int days = DateTime.Now.Subtract(linq.ENTRY_DATE.value).Day;
 
Mike Banavige
~~~~~~~~~~~~

Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
0
mbanavige
2/12/2009 4:33:19 AM

Works great!

 

thanks

0
BellaScout
2/12/2009 5:16:01 AM
Reply: