שתף באמצעות


HOW CAN I GET START DATE AND END DATE OF A MONTH USING CURRENT SYSTEM DATE TIME

Question

Wednesday, August 13, 2014 8:41 AM

ASSUME THAT MY CURRENT DATE IS = #10-10-2014# ( MM-DD-YYYY) FORMAT

MY ANSWER SHOULD BE LIKE THIS 

 START DATE = #10-01-2014#

END DATE  = #10-31-2014#

VB.NET

Renish Abdul Rehiman

All replies (3)

Thursday, August 14, 2014 4:22 AM ✅Answered

Hi Renish,

You can calculate them like this:

Dim testDate As Date = CType("10-10-2014", Date)
Dim FirstDay = testDate.AddDays((testDate.Day - 1) * -1)
Dim LastDay = New Date(testDate.Year, testDate.Month + 1, 1).AddDays(-1)
Console.WriteLine("FirstDay: " & FirstDay.ToString("MM-dd-yyyy"))
Console.WriteLine("LastDay: " & LastDay.ToString("MM-dd-yyyy"))

Screenshot:

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.


Wednesday, August 13, 2014 9:28 AM

Hey Renish,

Check this out. DateTime.

Hope this helps !! 

Regards, Ram.


Thursday, August 14, 2014 6:38 AM

Just as addition to Franklins answer. 

VB has some optimized conversion functions, which are very easy to use.

Dim testDate = CDate("10-10-2014")

http://msdn.microsoft.com/en-us/library/1bbh5ae4.aspx

Success
Cor