开发者

Check for datetime

开发者 https://www.devze.com 2022-12-22 06:17 出处:网络
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 gettin

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 usin开发者_如何学Gog c# with MySql


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消