Click here to Skip to main content
15,073,911 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Anyone can help me how to track the date in my database for daily, weekly, monthly. Im creating an sales report for daily, weekly and monthly.

Thanks in advance.
Posted
Comments
Siva Hyderabad 17-Feb-14 4:15am
   
what have you tried so far?

1 solution

Hey, you can do like

For Daily Write SQL Like
SQL
Select Day(getdate()) as Daily from table_name group by Daily


For Monthly Write SQL Like
SQL
Select Month(getdate()) as Monthly from table_name group by Monthly


For Yerly Write SQL Like
SQL
Select Year(getdate()) as Yearly from table_name group by Yearly



Just replay the getdate() Function with your date column name and table_name with your table name.

Thats ALL :-)
   
Comments
DLSU-D Student 17-Feb-14 4:47am
   
I have a database table that is:

Item_Purchased_Number nvarchar(50)
Email_Address nvarchar(100)
ProductID numeric(18, 0) Checked
productName nvarchar(50)
quantity int
Branch nvarchar(50)
Date_Purchased nvarchar(50)

How can I track if Date_Purchased from daily, weekly and monthly?
DLSU-D Student 17-Feb-14 4:49am
   
This is my code:
protected void Page_Load(object sender, EventArgs e)
{
string strQuery = "Select Item_Purchased_Number,ProductID,ProductName,quantity,Branch, Date_Purchased from Customer_Purchased Where Branch = 'PureGold Bacoor'";
SqlCommand cmd = new SqlCommand(strQuery);
DataTable dt = GetData(cmd);
GridView1.DataSource = dt;
GridView1.DataBind();
}
private DataTable GetData(SqlCommand cmd)
{
DataTable dt = new DataTable();
String strConnString = System.Configuration.ConfigurationManager.ConnectionStrings["CellzoneDatafilesConnectionString1"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
SqlDataAdapter sda = new SqlDataAdapter();
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
try
{
con.Open();
sda.SelectCommand = cmd;
sda.Fill(dt);
return dt;
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
sda.Dispose();
con.Dispose();
}
}

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