VB.Net Days Between Dates -


i'm trying calculate days have passed between today , date in past using following code:

 caseopendays.text = (datetime.now.subtract(cdate(datereported.text))) 

where caseopendays label , datereported.text label.

i'm having error thrown:

value of type 'system.timespan' cannot converted 'string'

what missing here?

you have use timespan.days or timespan.totaldays:

dim timesincereporting timespan = datetime.now - cdate(datereported.text) caseopendays.text = cint(timesincereporting.totaldays).tostring() 

another way timespan.tostring:

caseopendays.text = timesincereporting.tostring("dd") 

Comments