4
Answers

How to convert day, month and year into month and year

Photo of Lucas Ngobeni

Lucas Ngobeni

9y
401
1
Hi Everyone

I have table called MCALLERS on my database that has column which called CallDate, datatype is datetime stored data as 2016-02-01 17:01:00.000

on my web Form I have dropdownlist which is populating month and year as March-2016.

how to convert datetime into month and year when I search data.I want to search data from database using Month and year as (March-2016). I'm sing C#.

Thanks in advance
 
what I have tried
 
 
 
select BusinessCallYN,CallID,NewNam,CallDate,CalledNo,CallExt,CallDuration,Amount,tmpNewNam from MCALLERS where UserName='"+txtEmail+"' and CallDate>='"+cmddropdownlist1+"' and CallDate<'"+cmddropdownlist1+"' and Amount>0 order by CallDate

Answers (4)

0
Photo of Santhosh Kumar Jayaraman
NA 9.9k 2.3m 12y
When You are deleting records,

You can write query as

delete table AU_Delete

or
delete from table au_Delete.

you have to use * only in select queries.

try this

 SqlConnection con = new SqlConnection("Data Source=APPLE;Initial Catalog=sam;Integrated Security=True");
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            con.Open();
            string str1 = "DELETE  AU_Delete";
            cmd.CommandText = str1;
            cmd.ExecuteNonQuery();
            con.Close();
          

0
Photo of Hemant Kumar
NA 3k 215.2k 12y
Mohammed Shamsheer,

you can't write '*' for the delete Statements

string Query="delete from AU_DELETE";
0
Photo of Naresh Avari
NA 811 1.6m 12y
Hi,

Remove '*' from your SQL Query and use

string str1 = "DELETE FROM AU_Delete";

You don't need to specify '*' for DELETE statement.