user123
7 years agoIdeator I
How to find the date difference from 2 fields.
Hi i have a question and i would really love to get help. i currently allow user to select a start and a end date. with this information i want to calculate the number of days. I have tried coding this myself but i keep getting errors.
string startDtStr = this.getProperty("start_date","");
string endDtStr = this.getProperty("end_date","");
if (startDtStr =="" || endDtStr=="")
{
return inn.newError("Select a Start and a End Date");
}
DateTime startDt = DateTime.Parse(startDtStr);
DateTime endDt = DateTime.Parse(endDtStr);
string durationStr = this.getProperty("duration");
int duration = (int)(endDt - startDt).TotalDays
It gives me a number of errors and it just doesnt like the code.
Can someoene please help me.
Thank you.
Hi,
you need to do a range check. This sample from an old draft of mine contains a separate class for the Data Range calculation that may work for your use case too:
If you skip the activity stuff, you should be able to reuse where ever you want with this call:
var body = "<start_date_>" + dateStart + "</start_date_>" +
"<end_date_>" + dateEnd + "</end_date_>";
var result = aras.applyMethod("MyMethodname",body);