Have you considered that you are reinventing the wheel?
Perhaps there is a function of the datetime variety that will do all this for you..
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
Try with DateTme.TryParse method .let me know it is working for u.
srikanthkadem
Junior Poster in Training
68 posts since Mar 2008
Reputation Points: 11
Solved Threads: 11
I was trying to get you to look at the datetime functions for yourself to find the things like tryparse..
Perhaps you will now try and do a search on date time formats.
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
i put in 22/03/09 originally then the program works out whether the day needs a nd, st, rd or th at the end of it and then outputs like this;
i did not get this words..can u explain indetails so that i can help u...
srikanthkadem
Junior Poster in Training
68 posts since Mar 2008
Reputation Points: 11
Solved Threads: 11
Check out this:
string dateString;
DateTime dateValue;
Console.WriteLine("please insert a date");
dateString =Console.ReadLine();
if (DateTime.TryParse(dateString, out dateValue))
{
//it is a date
}
else
{
//error
}
Flush goto's...
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
Check out this:
string dateString;
DateTime dateValue;
Why do you do this? This is not C. Predeclaration makes code less readable.
Rashakil Fol
Super Senior Demiposter
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
Hi Foxipj,
dateValue.ToString("dd MMMM,yyyy");
use this line in if condition .where datevalue is datetime object in ur code.
and u can play with this Tostring method as well for different formats.
srikanthkadem
Junior Poster in Training
68 posts since Mar 2008
Reputation Points: 11
Solved Threads: 11
Why do you do this? This is not C. Predeclaration
I know this is an old habbit I got from my Modula-2 times.
Thanks for reminding me.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
Take a read of the helpfile, there are many date/time formats, its very simple, but you should start reading for yourself what options you have.
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
It gets really tiring to see people who dont try and then expect others here to do the work. I know theres no date format that does the suffix, which is why I got you to look. If you google there are plenty of functions out there prewritten you can use to do it.
I too know theres no built in function to do it, it seems kind of a large oversight IMHO, but, there isnt. However, like most things like this, someone already has hit this and written something to do it. I got back a lot of hits with sensible code from google.
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190