Click here to Skip to main content
14,388,907 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,

I want to fetch Max date in MM-dd-yyyy format using number 0 to 9 and without using any in built function e.g. MaxDate

Please help

What I have tried:

tried to form look up table but not succeeded
Posted
Updated 21-Aug-19 9:34am
Comments
phil.o 21-Aug-19 13:08pm
   
"I want" is not a question. Please read the FAQ and reformulate your post to a proper question. Stop trying to type as few characters as possible, and provide some relevant details about your issue.
srishti_ 22-Aug-19 1:40am
   
Thanks for your comment i don't know what detail you want in this short question but if you are not able to understand you can ask simply for the detail rather then giving a meaningless comment i am not trying to write few character this question is short and just for writing i can not write unnecessary things to create more confusion i wrote it as per my requirement. Also if you cant see it in proper way you can leave thanks again
Rate this:
Please Sign up or sign in to vote.

Solution 1

Well, the MM and dd parts are really obvious: MM = 12, dd = 31. The year is also simple: 9999
So:
DateTime max = new DateTime(9999, 12, 31, 23, 59, 59);

But ... DateTime.MaxValue is a lot simpler and more obvious.
   
Comments
Maciej Los 21-Aug-19 14:34pm
   
5ed!
Rate this:
Please Sign up or sign in to vote.

Solution 2

Well, a format of date is the string representation of date, not a date itself!

So, if you want to get max value, use DateTime.MaxValue[^] - as OriginalGriff said.
To display MM-dd-yyyy format, use ToString()[^] method.
   
Comments
srishti_ 22-Aug-19 1:34am
   
yes this is the way i can use but i want it without MaxValue function
Maciej Los 22-Aug-19 1:56am
   
Then follow the OriginalGriff's instruction ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100