my goal => 5/26/2022
but I can’t remove time from date. => 5/26/2022 12:00:00 AM
How can I remove the time without using ToShortDateString()?
Value.Date.ToShortDateString()
Example;
https://dotnetfiddle.net/xWELRP
my goal => 5/26/2022
but I can’t remove time from date. => 5/26/2022 12:00:00 AM
How can I remove the time without using ToShortDateString()?
Value.Date.ToShortDateString()
Example;
https://dotnetfiddle.net/xWELRP
3
Answers
You could try with
if your variable is type of DateTime,itwould have hour minute and second by default,it would set the time to 0:00:00
If you are using .Net6, then you can use
DateOnly
struct,.Net Fiddle
You can just write like this:
There are a few other format constraint keywords where you can find the one that works best for you, this is a very easy way to do it.