Hi,

I am working on a project in which i've to identify a textbox value,

The end user may enter a date (dd\mm\yyyy) or may enter a ticket number (alphanumeric:ex:'VD103'),

can anyone tell me how to distinguish the date or string values entered in the textbox so that depending upon that i am able to connect to the database

Kiran.

My code looks like this
I've used the datetime.exactparse to distinguish between date and string
but
error is that we cannot use
DateTime.ParseExact(strByDateByTkt, strformat, CultureInfo.InvariantCulture) as a bool type

what should i do

public void btnByDayByTktGo_Click(object sender, EventArgs e)
    {
        objCommon = new HDCommon();
        string strVenName = ddlVenTktLog.SelectedValue.ToString().Trim(),
               strStatus = ddlVenTktStatus.SelectedValue.ToString().Trim(),
               strByDateByTkt = txtVenTktSrchByDayByTkt.Text.ToString().Trim(),
               strformat="dd/mm/yyyy",
               strMode = "C",
               strCheckId="";

     if ((DateTime.ParseExact(strByDateByTkt, strformat, CultureInfo.InvariantCulture)))
        {
                BindGrid(strVenName, strStatus, "", "", strMode,                                
                      objCommon.DateFormat(strByDateByTkt,"MM/DD/YYYY"), "");
        }
        else
        {            
            BindGrid(strVenName, strStatus, "", "", strMode, strByDateByTkt, "");
        }
    }

Edited 6 Years Ago by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

I have no clue what you are trying to do.

Please use code tagging.
try

if (DateTime.Compare(DateTime.ParseExact(strByDateByTkt, strformat, System.Globalization.CultureInfo("en-US")), new DateTime(2010, 03, 15)) == 0))
{

==0 means the date is equal
< 0 means the right date is less than the left date
> 0 meand the right date is higher than the right date.

This article has been dead for over six months. Start a new discussion instead.