Getting first day of the month

Asked By sarah lee
05-Feb-07 09:34 AM
Earn up to 0 extra points for answering this tough question.
Hi All,

I want to set two textboxes, where I want to set the first day of current month in one textbox, and todays date in the second text box.

How can I get the first day of the current month?

Thanks In advance

  RE:Firstday of month

Sushila Patel replied to sarah lee
05-Feb-07 09:43 AM

You can try

Public Shared Function GetFirstDateOfMonth(ByVal date As DateTime) As DateTime
 Return (New DateTime(date.Year, date.Month, 1))
End Function

  first day of the month

sundar k replied to sarah lee
05-Feb-07 11:35 AM
you can choose between DateTime.Now.Day or DateTime.Now.ToString("dd")

  Have you tried this?

Robert Stanton replied to sarah lee
05-Feb-07 12:06 PM

//First day of month
textBox1.Text = (new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)).ToString();

//Current day
textBox2.Text = DateTime.Now.ToString();

 

  thanks everyone, i got it
sarah lee replied to Robert Stanton
05-Feb-07 01:44 PM
end of post
Create New Account