Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
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 8: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

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.
 
Share this answer
 
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 ;)
Well, the MM and dd parts are really obvious: MM = 12, dd = 31. The year is also simple: 9999
So:
C#
DateTime max = new DateTime(9999, 12, 31, 23, 59, 59);

But ... DateTime.MaxValue is a lot simpler and more obvious.
 
Share this answer
 
Comments
Maciej Los 21-Aug-19 14:34pm    
5ed!

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900