Search This Blog

Monday, April 7, 2014

Get Date Part in SQLCE in dd/mm/yy format

string Query = "SELECT DATEPART(day, CreatedDate) AS Date,DATEPART(month, CreatedDate) AS month, DATEPART(year, CreatedDate) AS Year, COUNT(*) AS TotalRegistrations FROM OutBoundCalls WHERE (CreatedDate > '12 April 2010') AND (CreatedDate < '25 June 2014') AND (Status = 'Registered') GROUP BY DATEPART(day, CreatedDate), DATEPART(month, CreatedDate), DATEPART(year, CreatedDate)";


DataSet ds = Db.GetData(Query);


foreach (DataTable table in ds.Tables)
{
foreach (DataRow dr in table.Rows)
{
DateTime date = Convert.ToDateTime(dr["month"] + "/" + dr["Date"] + "/" + dr["Year"]);
}
}