Click here to Skip to main content
15,395,181 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, iam using asp.net with c#

in datetime i have to add 2 days and i have to display date part seperate and time part seperate, iam using this format can you help me how to get date part and time part.

C#
System.DateTime now = System.DateTime.Now;
 System.DateTime modifieddate = now.AddDays(2);
Posted
Updated 26-Jun-12 20:35pm
v2

Try this:
C#
dateTime = DateTime.Now.AddBusinessDays(4);

Use Fluent DateTime[^]

Have a look on:
DateTime.Add Method[^] & DateTime.AddDays Method[^]

Refer similar thread:
Adding Days to a Date[^]
   
Comments
Vani Kulkarni 27-Jun-12 2:56am
   
Clean and Clear! 5!
Prasad_Kulkarni 27-Jun-12 3:01am
   
:) Thanks Vani!
DateTime dNow = DateTime.Now;
DateTime dNow1 = dNow.AddDays(2);
txt_date.Text = (dNow1.ToString("dd/MM/yyyy"));
txt_time.Text = (dNow1.ToString("hh:mm"));


I hope Its Help You.
   
v3
Comments
Mohamed Mitwalli 27-Jun-12 2:43am
   
5+
[no name] 27-Jun-12 5:23am
   
5+ good one
developerit 30-Jun-12 2:40am
   
thanks it helps me a lot
for date part:
C#
dToday = DateTime.Now.[Date]


for time part:
C#
dToday = DateTime.Now.[Time]


Hope so it will work
   
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900