Time Range: this week, this month, and this year

Source: Internet
Author: User
                   Case   "  Within this week  " :
Datetime retstartday = datetime. Now. Date. adddays (-( Int ) (Datetime. Now. dayofweek) + 1 );
Datetime retendday = datetime. Now. Date. adddays ( 7 -( Int ) (Datetime. Now. dayofweek). adddays ( 1 );
Sbsqldate. append ( " Joindate> =' " + Retstartday + " 'And joindate <=' " + Retendday + " ' " );
Break ;
Case " Within this month " :
Datetime monthstart =New Datetime (datetime. Now. Year, datetime. Now. Month, 1 );
Datetime monthend = New Datetime (datetime. Now. Year, datetime. Now. Month + 1 , 1 ). Adddays (- 1 );
Sbsqldate. append ( " Joindate> =' " + Monthstart + " 'And joindate <=' " + Monthend + " ' " );
Break ;
Case " Within this year " :
Datetime yearstart = New Datetime (datetime. Now. Date. Year, 1 , 1 );
Datetime yearend =New Datetime (datetime. Now. Date. Year + 1 , 1 , 1 ). Adddays (- 1 );
Sbsqldate. append ( " Joindate> =' " + Yearstart + " 'And joindate <=' " + Yearend + " ' " );
Break ;
List <radio> radlist = radgrop. checkeditems;
Foreach (Radio item In Radlist)
{
Switch (Item. boxlabel)
{
Case " Do not remember " :
Break ;
Case " Yesterday " : Sbsqldate. append ( " Createdate> =' " + New Datetime (datetime. Now. Year, datetime. Now. Month, datetime. Now. Day). adddays (- 1 ) + " And createdate <' " + New Datetime (datetime. Now. Year, datetime. Now. Month, datetime. Now. Day) +" ' " );
Break ;
Case " Today " : Sbsqldate. append ( " Createdate =' " + Datetime. Now. Date + " ' " );
Break ;
Case " Past 7 days " : Sbsqldate. append ( " Createdate> =' " + Datetime. Now. adddays (- 7 ) + " And createdate <=' " + Datetime. now + " ' " );
Break ;
Case " Past 30 days " : Sbsqldate. append ( " Createdate> =' " + Datetime. Now. adddays (- 30 ) + " And createdate <=' " + Datetime. now + " ' " );
Break ;
Case " Within this week " :
Datetime retstartday = datetime. Now. Date. adddays (-( Int ) (Datetime. Now. dayofweek) + 1 );
Datetime retendday = datetime. Now. Date. adddays ( 7 -( Int ) (Datetime. Now. dayofweek). adddays ( 1 );
Sbsqldate. append ( " Createdate> =' " + Retstartday + " And createdate <=' " + Retendday + " ' " );
Break ;
Case " Within this month " :
Datetime monthstart = New Datetime (datetime. Now. Year, datetime. Now. Month, 1 );
Datetime monthend = New Datetime (datetime. Now. Year, datetime. Now. Month + 1 , 1 ). Adddays (- 1 );
Sbsqldate. append ( " Createdate> =' " + Monthstart + " And createdate <=' " + Monthend + " ' " );
Break ;
Case " Within this year " :
Datetime yearstart = New Datetime (datetime. Now. Date. Year, 1 , 1 );
Datetime yearend = New Datetime (datetime. Now. Date. Year + 1 , 1 , 1 ). Adddays (- 1 );
Sbsqldate. append ( " Createdate> =' " + Yearstart + " And createdate <=' " + Yearend + " ' " );
Break ;
Case " Specified Date " : Sbsqldate. append ( " Createdate> =' " + Dfstatedate. Text. Trim () + " And createdate <=' " + (Dfenddate. Text. Trim () = " 0001-1-1 0:00:00 " ? Datetime. Now. tostring (): dfenddate. Text. Trim () + " ' " );
Break ;
}
}

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.