Thursday, 23 May 2013

Write an SQL Query to check whether date passed to Query is date of given format or not?


SQL has IsDate() function which is used to check passed value is date or not of specified format ,it returns 1(true) or 0(false) accordingly.

SELECT  ISDATE('1/08/13') AS "MM/DD/YY";

Tuesday, 21 May 2013

Standard Date Time Format - C#


   DateTime dtDate;
   string strDate;
   strDate = string.Format("{0:d}", Convert.ToDateTime(dr["dtDate"]));
   dtDate = Convert.ToDateTime(strDate);
   strDate = dtDate.ToString("MM/dd/yyyy", new CultureInfo("en-US"));

Monday, 20 May 2013

RequiredFieldValidator and OnClientClick Together


function showContent()
{
    // if you need one group use    
    // Page_ClientValidate('VGFillHours');
    if (Page_ClientValidate())  //validates all groups
    {
        document.getElementById("<%=ImgAjaxloaderClarification.ClientID %>").style.display = "block";
    return true;
    }
return false;
}

Wednesday, 15 May 2013

How to remove diacritics (accents) from words in SQL Server


Select 'à éêöhello!' Collate SQL_Latin1_General_CP1253_CI_AI

Create Function [String].[RemoveDiacritics] ( @p_String Varchar(Max) )
Returns Varchar(Max) As
Begin
  Return @p_String Collate SQL_Latin1_General_CP1253_CI_AI;
End

Tuesday, 14 May 2013

validation expression for gmail,yahoo


<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"Display="Dynamic" ErrorMessage="Invalid Email" ValidationExpression="^([a-zA-Z0-9]+[a-zA-Z0-9._%-]*@(yahoo\.com|gmail\.com))"                                            ValidationGroup="reg"></asp:RegularExpressionValidator>