?
Solved

Get the first day of next month

Posted on 2015-02-18
4
Medium Priority
?
168 Views
Last Modified: 2015-02-18
This returns next month 03/18/2015. How can I get the begining of next month, 03/01/2015?

dim dt = DateTime.Today.AddMonths(1).ToString("MM/dd/yyyy")
0
Comment
Question by:VBdotnet2005
[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
  • Learn & ask questions
4 Comments
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 500 total points
ID: 40617131
dim dt = DateTime.Today.AddMonths(1).ToString("MM/dd/yyyy")
dt = new datetime(dt.year, dt.month, 1)
0
 
LVL 34

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 500 total points
ID: 40617134
        DateTime firstDay;
        DateTime myDate = Convert.ToDateTime("2/19/2015");
        int mon = myDate.Month;
        int year = myDate.Year;
        firstDay = new DateTime(year, mon, 1);
        Response.Write(firstDay.ToString());

Open in new window

0
 
LVL 34

Assisted Solution

by:it_saige
it_saige earned 500 total points
ID: 40617139
More simplified approach:
Module Module1
	Sub Main()
		Dim dt = New DateTime(Now.Year, Now.Month, 1).AddMonths(1)
		Console.WriteLine(dt.ToString("MM/dd/yyyy"))
		Console.ReadLine()
	End Sub
End Module

Open in new window

Produces the following output -Capture.JPG-saige-
0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40617162
Hi VBdotnet2005;

This should give you what you need.

Dim MyDate As Date = DateTime.Today
Dim DaysInMonth As Integer = DateTime.DaysInMonth(MyDate.Year, MyDate.Month)
Dim MonthStartDate As String = New DateTime(MyDate.Year, MyDate.Month, DaysInMonth).AddDays(1)

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question