Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Calculated the Date in C#

Posted on 2014-02-26
Medium Priority
255 Views
The system takes the current day you apply or check rates and adds the value in the Days to Close editor (30 days) to come up with an estimated closing date. From there, we figure out how many days are left in the month. If the estimated closing date falls on a Friday or the weekend, we moved the estimated closing date to the following Monday.

Using the application date or check rates date of 2/19/14, this means for your example, the average days to close is 30 which would put the closing date at March 20th. With a closing date of March 20th, the remaining days in the month would equal eight.

----Following is the code I had in C# but it is not calculating the Days Left In Month ----
---- It is calculating how many days left in a month ---

private state int retrieveInterestDays()
{
var today = DateTime.Now;
var day = today.Day;
var daysinmonth = DateTime.DaysInMonth(today.Year, today.Month);

return daysinmonth - day + 1;
}
0
Question by:eli411
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 4

LVL 40

Accepted Solution

Jacques Bourgeois (James Burger) earned 2000 total points
ID: 39889945
First of all, since you know that you are working with dates, do not create a var variable, create a DateTime. The compiler will be able to perform a better validation on your code, and you will gain a bit or performance.

Second, do not use DateTime.Now when you do not need the time. This can lead to problems later. Use DateTime.Today instead.

Thirdly, once you have a date, you can know which day of the week it falls with the DayOfWeek property, going from Monday (1) to Sunday(7).

Here is how I would perform you routine:

while (interestDate.DayOfWeek>DayOfWeek.Thursday)
{
}
0

LVL 2

Author Comment

ID: 39890281
Let me try and see if it work or not!  Thanks.
0

LVL 2

Author Comment

ID: 39890326
Hi JamesBurger:
The purpose of this function I want to find out how many business day left for the month after adding 30 days!  I am still testing it.
0

LVL 2

Author Comment

ID: 40037965
I've requested that this question be closed as follows:

Accepted answer: 500 points for JamesBurger's comment #a39889945
Assisted answer: 0 points for eli411's comment #a39890326

for the following reason:

Very good!
0

LVL 2

Author Comment

ID: 40037963
Found solution from other web sites!
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
These instructions are based on installing Owncloud on your new raspberry pi connected with a usb HDD. What do you need Part A? A Raspberry Pi, model B. A boot SD card for the Raspberry Pi. A usb HDD An Ethernet cable to connect to the lo…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
###### Suggested Courses
Course of the Month11 days, 13 hours left to enroll