tags:

views:

69

answers:

2

Hay.. I am facing a problem, I am getting a string 'strData' which contain user search value. I am splitting that string by space and putting in array. how can i check that the string which i getting from array is date or not? if is it date type so i will need to convert it in datetime.

I am using MySql as a database. I am doing like this

DATE_FORMAT(ProjectDueDate, '%m/%d/%Y') like '%3/9/2011%'

It is not working fine but if i take date like this '%03/09/2011%' then its working fine. How can i handle date like '%3/9/2011%'

I am using c# with MySql

+1  A: 

Assuming you are using the C# DateTime class, you can use the TryParse method. This will let you know whether the string contains a valid DateTime value or not.

a_m0d
+3  A: 

DateTime.TryParse

I am assuming it because you are a c#/asp.net developer per your SO profile :)
Please tag the question with language/tool so as not leave people guessing.

EDIT:

How about DATE_FORMAT(ProjectDueDate, '%c/%e/%Y')?
This is derived as per mysql date format documentation here.

%c Month, numeric (0..12)
%e Day of the month, numeric (0..31)

Hope that helps.

shahkalpesh
+1, Not for the answer..but for the extra effort taken to guess the language ;)
codaddict
Thanks codaddict. The answer will be of help now to the OP, I think.
shahkalpesh