Verification start date and end date

Source: Internet
Author: User
///   <Summary>
/// Verification end date is greater than or equal to the start date
///   </Summary>
///   <Param name = "startdate"> Start date </Param>
///   <Param name = "enddate"> End Date </Param>
///   <Param name = "curdbfield"> Database field corresponding to the verification date </Param>
///   <Param name = "filterexpression"> Condition </Param>
///   <Returns> True/false </Returns>
Private   Bool Validoraclestartenddate ( String Startdate, String Enddate, String Curdbfield, Out   String Filterexpression)
{
Filterexpression =   String . Empty;
String Startdatefilter =   " And {1 }>= to_date ('{0}', 'yyyy-MM-DD hh24: MI: ss ') " ;
String Enddatefilter =   " And {1} <to_date ('{0}', 'yyyy-MM-DD hh24: MI: ss ') " ;

// The start and end dates are empty.
If (Startdate =   Null   | Startdate. Length =   0 ) && (Enddate =   Null   | Enddate. Length =   0 ))
{
Return   True ;
}

Datetime sdate=Webcommon. tostartdatetime (startdate );
Datetime edate=Webcommon. toenddatetime (enddate );

// The start date is later than the end date.
If (Sdate > Edate)
{
Return   False ;
}
Else   // Start date is less than or equal to end date (correct)
{
Edate = Edate = Datetime. maxvalue ?
Datetime. maxvalue: edate. adddays ( 1 );
Filterexpression =   String . Format (startdatefilter, sdate, curdbfield );
Filterexpression + =   String . Format (enddatefilter, edate, curdbfield );
Return   True ;
}
}

///   <Summary>
/// Verification end date is greater than or equal to the start date
///   </Summary>
///   <Param name = "startdate"> Start date </Param>
///   <Param name = "enddate"> End Date </Param>
///   <Param name = "curdbfield"> Database field corresponding to the verification date </Param>
///   <Param name = "filterexpression"> Condition </Param>
///   <Returns> True/false </Returns>
Public   Static   Bool Validsqlserverstartenddate ( String Startdate, String Enddate, String Curdbfield, Out   String Filterexpression)
{
Filterexpression =   String . Empty;
String Startdatefilter =   " And convert (varchar (10), {1}, 120)> = '{0 }' " ;
String Enddatefilter =   " And convert (varchar (10), {1}, 120) <'{0 }' " ;

// The start and end dates are empty.
If (Startdate =   Null   | Startdate. Length =   0 ) && (Enddate =   Null   | Enddate. Length =   0 ))
{
Return   True ;
}

Datetime sdate=Object2startdate (startdate );
Datetime edate=Object2enddate (enddate );

// The start date is later than the end date.
If (Sdate > Edate)
{
Return   False ;
}
Else   // Start date is less than or equal to end date (correct)
{
Edate = Edate = Datetime. maxvalue ?
Datetime. maxvalue: edate. adddays ( 1 );
Filterexpression =   String . Format (startdatefilter, sdate. tostring ( " Yyyy-mm-dd " ), Curdbfield );
Filterexpression + =   String . Format (enddatefilter, edate. tostring ( " Yyyy-mm-dd " ), Curdbfield );
Return   True ;
}
}

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.