datetime搜索方法 [英] datetime methods for search

查看:67
本文介绍了datetime搜索方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

if (String.IsNullOrEmpty(tb_eventDateFrom.Text))
{
    msg1 = "Date From is empty, please re-select!";
    lb_msg.Text = msg1;
}
else
{
    var enCulture = new System.Globalization.CultureInfo("en-us");
    DateTime dateFrom = DateTime.ParseExact(tb_DateFrom.Text,"dd/M/yyyy",enCulture);
}



我正在做一个搜索功能所以这个方法对我不起作用,你怎么用其他方法自由搜索。


I am doing a search function so this method would not work for me, how would you search freely by using another method.

推荐答案

if (String.IsNullOrEmpty(tb_eventDateFrom.Text))
{
    msg1 = "Date From is empty, please re-select!";
    lb_msg.Text = msg1;
     return; // if any single value is not valid it will return...
}
else
{
    var enCulture = new System.Globalization.CultureInfo("en-us");
    DateTime dateFrom = DateTime.ParseExact(tb_DateFrom.Text,"dd/MM/yyyy",enCulture);
}


如果你改变这个,你可能会得到更好的结果:

You might get a better result if you change this:
DateTime dateFrom = DateTime.ParseExact(tb_DateFrom.Text, "dd/M/yyyy", enCulture);

对此:

To this:

DateTime dateFrom = DateTime.ParseExact(tb_DateFrom.Text, "dd/MM/yyyy", enCulture);



但是...你展示的代码确实如此根本没有搜索,所以我们无法以任何方式回答你的问题。


But...the code you show does not searching at all, so we can't answer your question in any otehr way.


这篇关于datetime搜索方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆