C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

I have prob with change day part of datetime in C#


Posted Date: 10 Jan 2009      Posted By: Thilan Nirodh Dhanapala      Member Level: Bronze     Points: 1   Responses: 3



how to change day part of datetime in c#
Datetime="11/01/2008"
i want to change only day part..
datetime.day=15
is that correct?
Thilan
BR
Thilan





Responses

Author: Pascal    10 Jan 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 1

Try using AddDays() to add days. Something like this.

DateTime dt = DateTime.Now;
DateTime newDt = dt.AddDays(2);



Author: Babu Akkandi    10 Jan 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Hi Thilan Nirodh Dhanapala,

This is Wrong.

In datetime.day is the read only property, here you can't assign any value, but you can read

so use adddays method

Ex:



DateTime DT = Convert.ToDateTime("11/01/2008");
DT= DT.AddDays(4);



Hope it Helps!

Thanks and Regards,
Babu Akkandi
Microsoft Technology



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : How can we load multiple tables in to Dataset?
Previous : dropdownlist inside datalist
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use