Check if String has a Valid Time
Posted on 2011-03-03
I have clients passing a string to my WCF Service for processing using an SQL SP. One of the parameters they pass is a String Value, which should be a DateTime in String Format. (Service does all TryParse etc..)
This must stay as it is, as other services use this which I can't change.
What I need to do is somehow Check the String server side, to see if the String has a valid time, as well as a Date, before I pass it to the SP. If it doesn't, I need to add a time of '23:59:59.997', if it has, then I leave it alone, because one the the clients has specified a Time in their request. (i.e. some clients pass '2011/2/21' other might pass '2011/2/21 14:14:00'.
The point is that sometimes a client passes a String with Date AND Time, other times the client may pass a Datetime in ShortDate format.
I can't change the client, so need to do the checking server side.