Hi
I have Date field& i want to display only Date format not time
Thanks
Hi
I have Date field& i want to display only Date format not time
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Tuhin PaulRank #7 · 71.9K reputationPosted Apr 3, 2023, 11:37 PM EDT
DateTime date = DateTime.Now; string formattedDate = date.ToString("yyyy-MM-dd"); // Or any other date format you prefer Console.WriteLine(formattedDate);DateTime.Now gets the current date and time, and then the ToString() method is called with the format string "yyyy-MM-dd". This format string specifies that only the year, month, and day parts of the date should be displayed, separated by dashes.
Tuhin PaulRank #7 · 71.9K reputationPosted Apr 3, 2023, 11:36 PM EDT
In C#, you can use the
ToString()method with a format string to display only the date part of aDateTimefield.