# How do I calculate Expense in 7days Based on date requested ?RSS

## 2 replies

Last post Jan 22, 2018 03:54 AM by Cloudfiers

• Cloudfiers

Member

36 Points

256 Posts

### How do I calculate Expense in 7days Based on date requested ?

Good day to all,

could you please help me, how do I calculate Expense based on DATETIME requested in 7 days will calculated the expense ?,

```var Expences = (from i in TRANSACTIONSISSUED
join r in ListTrans
on i.REQUESTNO.Trim() equals r.REQUESTNO.Trim()
where
i.DEPARTMENT.Trim() == DepName.Trim() &&
i.DATETIME.Month == month1 && i.DATETIME.Year == year
select new EXpenseTransactionViewModel
{
Month = i.DATETIME.Month,
Year = i.DATETIME.Year,
Department = i.DEPARTMENT,
Cost = i.COST,
Qty = i.QTY
}).ToList();

foreach (BudgetViewModel item in list)
{
double Expense = Expences.Where(e => e.Month == item.MONTH && e.week == item.WORKWEEK  && e.Year == item.YEAR && e.Department.Trim() == item.DEPARTMENTID.Trim()).Sum(e => e.Cost * e.Qty);
item.EXPENCES = Expense;
item.BALANCE = item.BUDGET - item.EXPENCES;
}
```

thank you.

• Cathy Zou

Star

8660 Points

2882 Posts

### Re: How do I calculate Expense in 7days Based on date requested ?

Jan 19, 2018 03:19 AM|Cathy Zou|LINK

Hi Cloudfiers

Is it?

https://forums.asp.net/t/2134386.aspx

What is the purpose of above code.

Why you need to get list of EXpenseTransactionViewModel (Expences),

After you get it, what you want to do next?

Do you have any questions about the code provided?

Best regards

Cathy

MSDN Community Support
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
• Cloudfiers

Member

36 Points

256 Posts

### Re: How do I calculate Expense in 7days Based on date requested ?

#### Cathy Zou

Hi Cloudfiers

Is it?

https://forums.asp.net/t/2134386.aspx

What is the purpose of above code.

Why you need to get list of EXpenseTransactionViewModel (Expences),

After you get it, what you want to do next?

Do you have any questions about the code provided?

Best regards

Cathy

Hi Cathy,

yes you are right, the purpose of the code above is
I want to get the expences every 7 days after i get it,
I want to display all the expences in View per workweek that's it,
I hope you understand my explanation, thank you.

my question in code provided , didn't display the expences..

thank you.