Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In Asp.Net How to get only date from a calender.
It is also giving me time .
I am using .Net frame work 3.5.
Posted

C#
DateTime dt = Convert.ToDateTime(Calendar1.SelectedDate.ToShortDateString());


or u can use ajax calender.
 
Share this answer
 
v2
Try this code...
C#
 CultureInfo info = new CultureInfo("en-US", false);
 DateTime Fdob = new DateTime(1900, 1, 1);
DateTime.TryParseExact(yourdate.ToString().Trim(),"dd/MM/yyyy", info,
                                                                                                           DateTimeStyles.AllowWhiteSpaces, out Fdob))
 
Share this answer
 
Try this:
You can use ToShortDateString function of calender to display date only.
Try this:
C#
string date = Calendar1.SelectedDate.ToShortDateString();

Or you can also use ToString function to display the date only.
C#
string date = Calendar1.SelectedDate.ToString("dd/MM/yyyy");




--Amit
 
Share this answer
 
DateTime now = DateTime.Now;
Console.WriteLine(now.ToString("d"));


Hope this help.
 
Share this answer
 

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