0

I have a column named date of data type date in database. I am inserting data using CURDATE(). But when I retrieve data instead of showing only date it also showing time enter image description here. I am using MySQL databse and C# language. How to get only date not time. I retrieve data in rdlc report.

Rami Far
  • 406
  • 1
  • 10
  • 29
  • 1
    It is not clear what the display context is. More details on the problem are needed for a relevant solution to be recommended. – theMayer Mar 07 '17 at 17:08

3 Answers3

2

Use this to show the date in short date format:

yourDate.ToString("d")

You can also have your own format, for example this:

yourDate.ToString("MM/dd/yyyy HH:mm");

MSDN has a nice list of possible date formats here: https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx

To do this in a RDLC report, take a look at the following link: How to Change Date Format in .net RDLC Report?

Community
  • 1
  • 1
Timo Salomäki
  • 7,099
  • 3
  • 25
  • 40
0

If you want to show the date in your current culture you can use ToShortDateString() method detailed here in the docs.

string dateString = DateTime.Now.ToShortDateString();
maccettura
  • 10,514
  • 3
  • 28
  • 35
0

Date and time you can use

YourDate.ToString("dd/MM/yyyy HH:mm:ss");

In database you also select data type is Date and Time