Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
following is my code...
C#
public DataSet Admininformsale()
{
   try
   {
      SetConnection();
      sql_con.Open();
      sql_cmd = sql_con.CreateCommand();          
      string CommandText = "select Category,Compname,TDiscount,City,Area,Venue,DetailsOfDiscount,Emailid,Convert(char(8),SDate,10)as SDate,Convert(char(8),EDate,10) as EDate from offsale.OS_Informsale where Approval='False' and datediff(day,EDate,getdate())<=0 order by Category";           
      da = new SqlDataAdapter(CommandText, sql_con);
      DataSet ds = new DataSet();
      da.Fill(ds);
      return ds;
   }
   catch (Exception ex)
   {
      return null;
   }

   private DataTable AdminInformshow()
   {
      //SqlConnection sql_con;
      My_Util Util = new My_Util();
      try
      {
         // string CommandText;
         SqlCommand sql_cmd;
         SqlDataAdapter da;
         Util.SetConnection();
         sql_cmd = Util.sql_con.CreateCommand();
         string CommandText = "select Category,Compname,TDiscount,City,Area,Venue,DetailsOfDiscount,Emailid,CONVERT(CHAR(8),SDate,10)as SDate,CONVERT(CHAR(8),EDate,10) as EDate from offsale.OS_Informsale where Approval='False' and datediff(day,EDate,getdate())<=0 order by Category";
         da = new SqlDataAdapter(CommandText, Util.sql_con);
         DataTable dt = new DataTable();
         da.Fill(dt);
         return dt;
     }
     catch (Exception ex)
     {
        return null;
     }
}
Posted
Updated 15-Feb-13 4:26am
v2

1 solution

CONVERT(varchar(10), EDate, 103)

should convert date to the format you are looking for. See http://msdn.microsoft.com/en-us/library/ms187928.aspx[^] for more details.
 
Share this answer
 
Comments
nityasri 15-Feb-13 11:39am    
@chris...thanks a lot sir...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900