Home All Groups Group Topic Archive Search About

interesting fact about date.

Author
11 Jun 2005 1:35 AM
Kenny M.
hi

I have not seen anything yet that can help me with this.

All the time my page is loaded I need to show inside a TextBoxt the first
day of the month:

If the page is being loaded this month the textboxt should have

06/01/2005

If the page is being loaded the next month the textboxt should have

07/01/2005

If the page is being loaded at december:

12/01/2005

any sug?


--
Kenny M.

Author
11 Jun 2005 2:29 AM
Ryan Hancock
Depending on your needs, you could try setting the Text of the TextBox to a
serialized string that you make.  Grab the Month and Year parts of the
current month and put '/01/' between them and assign that string to the Text
property.

This may not work as well if you have a localized app where user format
settings take effect.  Is this the case?

HTH,
-Ryan

Show quoteHide quote
"Kenny M." wrote:

> hi
>
> I have not seen anything yet that can help me with this.
>
> All the time my page is loaded I need to show inside a TextBoxt the first
> day of the month:
>
> If the page is being loaded this month the textboxt should have
>
> 06/01/2005
>
> If the page is being loaded the next month the textboxt should have
>
> 07/01/2005
>
> If the page is being loaded at december:
>
> 12/01/2005
>
> any sug?
>
>
> --
> Kenny M.
Are all your drivers up to date? click for free checkup

Author
11 Jun 2005 2:43 AM
WJ
int d=(DateTime.Now.Day-1)*-1; //today-1
DateTime date1=DateTime.Now.AddDays(d); //move back d days
txt1stDayOfMonth.Text="1st Day: "+string.Format("{0:MM/dd/yyyy}",date1);
//show it

Is that what you want ?

John

Bookmark and Share