varsha dodiya

varsha dodiya

  • NA
  • 407
  • 73.7k

Crystal Report, showing record of current day only

Sep 4 2014 1:27 AM
Geeks, 
     I am using crystal report in my project in which i am having some btns (month,Day,Year) like when i click any btn among them report data should be shown only of that current month or day or year.  i did this somehow for month btn .

private void button4_Click(object sender, EventArgs e)
        {//month
            crystalReportViewer1.ReportSource = null;
            DateTime dtFrom = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
            DateTime dtTo = dtFrom.AddMonths(1).AddDays(-1);
            
            if (ReportName == "SalesReport")
            {
                Report.RecordSelectionFormula = String.Format("{0} >= CDate({1:yyyy,MM,dd}) And {0} <= CDate({2:yyyy,MM,dd})", "{BILLH.B_date}", dtFrom, dtTo);
                crystalReportViewer1.ReportSource = this.Report;
                crystalReportViewer1.Refresh();
            }
            else if (ReportName == "PurchaseReport")
            {
                Report.RecordSelectionFormula = String.Format("{0} >= CDate({1:yyyy,MM,dd}) And {0} <= CDate({2:yyyy,MM,dd})", "{PRO_BILL.P_purdate}", dtFrom, dtTo);
                crystalReportViewer1.ReportSource = this.Report;
                crystalReportViewer1.Refresh();
            }

this code is working fine for month but now i want to do same for DAY btn ,i help me in this . thanks in advance .

Answers (2)