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 . I am using MySQL databse and C# language. How to get only date not time. I retrieve data in rdlc report.
Asked
Active
Viewed 577 times
0

Rami Far
- 406
- 1
- 10
- 29
-
1It 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 Answers
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
-
how to do it in report. I am getting report data through query builder – Rami Far Mar 07 '17 at 17:05
-
this is for built in date option in report. not for my case as I am getting already saved value. – Rami Far Mar 07 '17 at 17:13
-
@RamishaFarrukh I think it would be better to update the post to include more detail on how you're retrieving the data. – Timo Salomäki Mar 07 '17 at 17:17
-
thank you sir. i have tried one solution from the link you have shared and my problem is solved – Rami Far Mar 07 '17 at 17:19
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

Manohar Godase
- 109
- 4