Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 24262 |  Welcome, Guest!   Register  Login
 Home > Forums > VB.NET > how to handle date formats ...
Jerome

how to handle date formats

Replies: 1 | Posted by: Jerome on 4/16/2012 | Category: VB.NET Forums | Views: 339 | Status: [Member] | Points: 10  


I have a loan system.The pay day is every 25 of the month and its cu off is every 21 of the month.When the loaner applies before 21 of the month he/she will have the first pay date on the 25 of the month and its pay end date will depend on his term(1yr. or 2yrs.) and if he/she will apply after 21 of the month he/she will have its first pay date on the 25 of the next month.Kindly show a solution to my problem.Thanks!


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Dhiren.Kaunar@Gmail.Com
Dhiren.Kaunar@Gmail.Com  
Posted on: 4/17/2012 12:42:47 AM
Level: Starter | Status: [Member] | Points: 50

Resolved

int todaysDate = DateTime.Now.Day;
// This will retuns start date of the month
DateTime payDate=new DateTime(DateTime.Now.Year,DateTime.Now.Month,1);
if (todaysDate > 21)
{
payDate = payDate.AddMonths(1).AddDays(24); //25 of the next month
}
else
{
payDate = payDate.AddDays(24); //25 of the this month
}

The above solution is for the loner applies on 21st or before 21st of the month then it will return pay Date = 25th of the current month
If you are looking for the solution is for the loner applies on 21st or after21st of the month then

int todaysDate = DateTime.Now.Day;
// This will retuns start date of the month
DateTime payDate=new DateTime(DateTime.Now.Year,DateTime.Now.Month,1);
if (todaysDate >= 21)
{
payDate = payDate.AddMonths(1).AddDays(24); //25 of the next month
}
else
{
payDate = payDate.AddDays(24); //25 of the this month
}
Please Mark as answer if this solution is helpful for you

Thanks & Rgards,
Dhiren Kumar Kaunar

Jerome, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/20/2013 11:22:23 AM