can u plz tel me how to retrive only date from DateTime in C#.

ex: 06/03/2008 12:00:00
i need only date 06/03/2008 in my application.

label1.Text = dateTimePicker1.Value.ToShortDateString();

dateTimePicker1.Value.ToShortDateString();

here what is dateTimePicker1 means.
I tried with it but its giving error dateTimePicker1 name doesn't exist in the current context.
what should i write with this to get proper solution.

Hi,
dateTimePicker1 is a Control which displays the date and Time visually. This control help to select the date and time visually.
U can get currently selected date or Time using dateTimePicker1.Value dateTimePicker1.Value.ToShortDateString(); gets the Date in Short Format.
Also in DateTime class, ToShortDateString() is possible.
Ex

DateTime dateTime = new DateTime();
    MessageBox.Show ( dateTime.ToShortDateString() );

Hi,
You can format the DateTime like:

DateTime dt = new DateTime();
System.Concole.Write( dt.ToString("dd/MM/yyyy")

or the format that you like.

But im using c# in web application. datetime stored in DB, but what i need is only date is displayed in reports. what can i do???

Yes I also have working on c# web application and need the date with time also from the database and I use code like below:

textBoxName.Text = DateTime.Now.ToShortDateString();

I'm not sure it is the one you need or not.

The original post was in 2008 and was marked as solved, the last poster resurected it in 2009; Do you really think they are still waiting for an answer to this question??

Please try not to ressurect old threads.

How to get the date of the system then store it to my database?
Can someone help me?

DateTime.Now returns a DateTime containing the current system date and time... it's in the posts above. Did you read the zombie thread before refreshing it?

hi i would like know how to convert date into milliseconds

Please try this DateTime.Now.Millisecond;

can u plz tel me how to retrive only date from DateTime in C#.

ex: 06/03/2008 12:00:00
i need only date 06/03/2008 in my application.

You can use ToShortDateString() Method to get only Data take a look in a demo

DateTime dt = new DateTime();
Console.WriteLine(dt.ToString()); // Gives you 06/03/2008 12:00:00
Console.WriteLine(dt.ToShortDateString());//Gives you what u want

Could any one please help me how to get the date from 1st January 2012 11:11 am as 01\01\2011 which in the format dd\mm\yyyy?

Hello, how do you set the start time and end time through the use of textbox only by entering the time it will start and the time it will end. Thanks... hope you can answer my question

Fetch Date into Databse and Display All The Details Of Yhis Date.

But Problem Date Format : dd/MM/yyyy

Eample:
SqlDataAdapter da = new SqlDataAdapter("select * from customer3 where Date= '"+txtdate.Text+"'", con);
Datatable dt=new Datatable;
da.Fill(dt);

Description:
txtdate.text input date are not match in database How this problem are solved

plz.

This thread has already been solved.
If you can read you could have seen it is marked:
This question has already been solved: Start a new discuion instead.
In your new thread and question you can always include a link to this one.
Here you will never get an answer I guess.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.