Development logs: Collect data every day, every month, and every week of each month.

Source: Internet
Author: User

Daily per month

Public Dataset monthdaylist (datetime DT)
{
Stringbuilder strsql =   New Stringbuilder ();
Strsql. append ( " Select datenum, planid, sum (dayclick) as sumcount, dateupdated " );
Strsql. append ( " From va4_sumdaycount " );
Strsql. append ( " Where datediff (month, dateupdated, @ dt) = 0 " );
Strsql. append ( " And planid = @ planid group by datenum, planid, dateupdated " );
Strsql. append ( " Order by datenum DESC " );
Sqlparameter [] P = {
Sqlhelper. makeinparam ( " @ Dt " , Sqldbtype. datetime, 8 , DT ),
Sqlhelper. makeinparam ( " @ Planid " , Sqldbtype. Int, 4 , _ Id)
};
Return Sqlhelper. executedataset (clsconfig. Conn, commandtype. Text, strsql. tostring (), P );
}

By monthly week

Public Dataset monthweeklist (datetime DT)
{
Stringbuilder strsql =   New Stringbuilder ();
Strsql. append ( " Select cast (datepart (wk, dateupdated) as varchar) as dateweek, sum (dayclick) as sumcount " );
Strsql. append ( " From va4_sumdaycount where planid = @ planid and datediff (year, dateupdated, @ dt) = 0 " );
Strsql. append ( " Group by cast (datepart (wk, dateupdated) as varchar) order by dateweek DESC " );
Sqlparameter [] P = {
Sqlhelper. makeinparam ( " @ Planid " , Sqldbtype. Int, 4 , _ Id ),
Sqlhelper. makeinparam ( " @ Dt " , Sqldbtype. datetime, 8 , DT)
};
Return Sqlhelper. executedataset (clsconfig. Conn, commandtype. Text, strsql. tostring (), P );
}

By year and month Public Dataset yearmonthlist (datetime DT)
{
Stringbuilder strsql =   New Stringbuilder ();
Strsql. append ( " Select substring (cast (datenum as varchar), 1, 6) as datemonth, sum (dayclick) as sumcount " );
Strsql. append ( " From va4_sumdaycount where planid = @ planid and datediff (year, dateupdated, @ dt) = 0 " );
Strsql. append ( " Group by substring (cast (datenum as varchar), 1, 6) " );
Strsql. append ( " Order by datemonth DESC " );
Sqlparameter [] P = {
Sqlhelper. makeinparam ( " @ Planid " , Sqldbtype. Int, 4 , _ Id ),
Sqlhelper. makeinparam ( " @ Dt " , Sqldbtype. datetime, 8 , DT)
};
Return Sqlhelper. executedataset (clsconfig. Conn, commandtype. Text, strsql. tostring (), P );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.