Filter Data Based on Time

How can i filter the data based on time. using oracle database, asp.net web form and query. oracle database outtime column datatype is date. Pls help

HTML

<!-- Main content -->
<section class="content">
  <div class="container-fluid">
      <div class="card">

          <div class="card-body">
              <div class="row">

                  <div class="col-md-3">
                      <div class="form-group m-0">
                          <label for="OrgList">Select a Floor</label>
                          <asp:DropDownList ID="FloorList" runat="server" CssClass="form-control select2" ClientIDMode="Static"></asp:DropDownList>
                      </div>
                      <!-- /.form-group -->
                  </div>

                  <div class="col-md-3">
                      <div class="form-group m-0">
                          <label for="OrgList">Select a Section</label>
                          <asp:DropDownList ID="SectionList" runat="server" CssClass="form-control select2" ClientIDMode="Static"></asp:DropDownList>
                      </div>
                      <!-- /.form-group -->
                  </div>

                  <div class="col-md-3">
                      <label>Search by date range:</label>
                      <div class="input-group">
                          <div class="input-group-prepend">
                              <span class="input-group-text">
                                  <i class="far fa-calendar-alt"></i>
                              </span>
                          </div>
                          <asp:TextBox runat="server" ClientIDMode="Static" ID="daterange" CssClass="form-control float-right" />
                          <span class="input-group-append">
                              <asp:Button runat="server" ID="attnFilter" Text="Run" OnClick="attendance_summary_report_Click" CssClass="btn btn-info btn-flat" />
                          </span>
                      </div>
                  </div>
                  <!-- /.input group -->
              </div>
          </div>
      </div>


      <!-- Main row -->
    <div class="row">
      <div class="col-md-12">
           <div class="card">
                <!-- /.card-header -->
                <div class="card-body">
                    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
                    <rsweb:ReportViewer ID="Attn_RV" runat="server"></rsweb:ReportViewer>
                </div>
                <!-- /.card-body -->
              </div>
              <!-- /.card -->
      </div>
    </div>
    <!-- /.row -->

</div>

jQuery

window.onload = function() {
  $(function() {
    $('#OrgList, #FloorList, #SectionList').select2({
      theme: 'bootstrap4'
    });
  })
}

//=== end function
let date = new Date();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);

$(document).ready(function() {
  //Date range picker
  $('#daterange').daterangepicker({
    startDate: firstDay,
    endDate: lastDay,
    ranges: {
      'Current Month': [moment().startOf('month'), moment().endOf('month')],
      'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
    },
    locale: {
      format: 'DD-MMM-YYYY'
    }
  });

});

Asp

    string date = (daterange.Text == "") ? DateTime.Now.ToString("dd-MMM-yyyy") + " - " + DateTime.Now.ToString("dd-MMM-yyyy") : daterange.Text;
    string[] datearr = date.Split(new[] { " - " }, StringSplitOptions.None);
    string from = datearr[0].Trim();
    string to = datearr[1].Trim();
    //ReportProduct(from, to, orgid);
  }
}

private void DropFloorData() {
  string orgid = Session["ORGID"].ToString();
  var item = OracleDbQuery.GetCompanies().Find(o => o.Companyid == orgid);

  using(OracleConnection con = DbConn.GetConnection(item.Companyid)) {
    string query = "select floor_id, floor_desc from floor order by floor_desc";
    OracleCommand cmd = new OracleCommand(query, con);
    cmd.CommandType = CommandType.Text;
    con.Open();
    OracleDataReader rdr = cmd.ExecuteReader();
    if (rdr.HasRows) {
      FloorList.Items.Clear();
      FloorList.DataSource = rdr;
      FloorList.DataValueField = "floor_desc";
      FloorList.DataTextField = "floor_desc";
      FloorList.DataBind();

      FloorList.Items.Insert(0, new ListItem("All Floor", "%"));
    } else {
      FloorList.DataSource = null;
      FloorList.DataBind();
      FloorList.Items.Insert(0, new ListItem("All Floor", "%"));
    }
  }
}

private void DropSectionData() {
  string orgid = Session["ORGID"].ToString();
  var item = OracleDbQuery.GetCompanies().Find(o => o.Companyid == orgid);

  using(OracleConnection con = DbConn.GetConnection(item.Companyid)) {
    string query = "select section_no, section_name from section order by section_name";
    OracleCommand cmd = new OracleCommand(query, con);
    cmd.CommandType = CommandType.Text;
    con.Open();
    OracleDataReader rdr = cmd.ExecuteReader();
    if (rdr.HasRows) {
      SectionList.Items.Clear();
      SectionList.DataSource = rdr;
      SectionList.DataValueField = "section_name";
      SectionList.DataTextField = "section_name";
      SectionList.DataBind();
      SectionList.Items.Insert(0, new ListItem("All Section", "%"));
    } else {
      SectionList.DataSource = null;
      SectionList.DataBind();
      SectionList.Items.Insert(0, new ListItem("All Section", "%"));
    }
  }
}

protected void attendance_summary_report_Click(object sender, EventArgs e) {
  string date = (daterange.Text == "") ? DateTime.Now.ToString("dd-MMM-yyyy") + " - " + DateTime.Now.ToString("dd-MMM-yyyy") : daterange.Text;
  string[] datearr = date.Split(new [] {
    " - "
  }, StringSplitOptions.None);
  string from = datearr[0].Trim();
  string to = datearr[1].Trim();
  string section = SectionList.SelectedItem.Value;
  string floor = FloorList.SelectedItem.Value;
  string orgid = Session["ORGID"].ToString();
  ReportProduct(section, floor, from, to, orgid);
}

public void ReportProduct(string section, string floor, string from, string to, string orgid) {
  Attendance_ds timecard_dt = GetData(section, floor, from, to, orgid);
  Attn_RV.ProcessingMode = ProcessingMode.Local;
  Attn_RV.SizeToReportContent = true;
  Attn_RV.Width = Unit.Percentage(100);

  Attn_RV.Height = Unit.Percentage(100);
  Attn_RV.ZoomMode = ZoomMode.Percent;
  Attn_RV.ZoomPercent = 100;
  Attn_RV.ShowZoomControl = true;
  Attn_RV.BackColor = System.Drawing.Color.DeepSkyBlue;

  foreach(RenderingExtension extension in Attn_RV.LocalReport.ListRenderingExtensions()) {
    if (extension.Name == "IMAGE" || extension.Name == "WORD") {
      FieldInfo fi = extension.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
      fi.SetValue(extension, false);
    }
  }

  Attn_RV.LocalReport.DataSources.Clear();
  Attn_RV.LocalReport.DataSources.Add(new ReportDataSource("AttendanceDataSet", timecard_dt.Tables[2]));
  Attn_RV.LocalReport.ReportPath = Server.MapPath("~/reports/attn_reports/attn_summary_individual.rdlc");
}

private Attendance_ds GetData(string section, string floor, string from, string to, string orgid) {
  CompanyInfo company = OracleDbQuery.GetCompanies().Find(o => o.Companyid == orgid);
  using(OracleConnection con = DbConn.GetConnection(company.Companyid)) {
    string query = OracleDbQuery.GetMonthlyAttendanceSummary(floor, section, from, to, company.Company_name);
    OracleCommand cmd = new OracleCommand(query, con);
    cmd.CommandType = CommandType.Text;
    con.Open();
    OracleDataAdapter sda = new OracleDataAdapter(cmd);
    sda.Fill(attn_ds, attn_ds.AttendanceSumIndv.ToString());
  }
  return attn_ds;

}
}

}

Oracle Query:

    WITH
    CTE_EmployeeSearchByTime AS(
        SELECTTO_CHAR(ad.att_date, 'DD-MM-YYYY') AS ATTDATE,
        eo.company_name AS COMPANY,
        eo.floor_desc AS FLOOR,
        eo.section_name AS SECTION,
        eo.line_info AS LINE,
        ep.empno AS EMPNO,
        ep.first_name AS NAME,
        eo.des_name AS DESIGNATION,
        TO_CHAR(ad.in_time, 'HH24:MI:SS') AS INTIME,
        TO_CHAR(ad.out_time, 'HH24:MI:SS') AS OUTTIME,
        ad.othour AS OTFROMemp_personal epLEFT
    JOIN emp_official eo ON
        ep.empno = eo.empnoLEFT
    JOIN attendance_details ad ON
        ep.empno = ad.empnoWHERETO_CHAR(ad.att_date, 'DD-MON-YYYY') = '{todate}' AND ad.status LIKE 'P' AND TO_CHAR(ad.out_time, 'HH24:MI:SS') BETWEEN '{starttime}' AND '{endtime}' AND eo.company_name = '{company}'
    )
SELECT
    * FROMCTE_EmployeeSearchByTimeORDER BYFLOOR,
    LINE,
    SECTION,
    TO_NUMBER(EMPNO) ASC

I want to try solve this issue. Please help. Thanks advance

New contributor

Sharif Ahmed Alif is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

4

Without some sample data and the expected result it’s hard to tell what you realy want. Here is a blind guess of sample data and a query which results with the dataset you could use for different reportings …

WITH    --  S a m p l e    D a t a :
    emp_personal ( EMPNO, FIRST_NAME ) AS
      ( Select  1, 'John' From Dual Union All
        Select  2, 'Jane' From Dual Union All
        Select  3, 'Kate' From Dual Union All
        Select  4, 'Mike' From Dual Union All
        Select  5, 'Anne' From Dual 
      ),
    emp_official ( ID, EMPNO, COMPANY_NAME, FLOOR_DESC, SECTION_NAME, LINE_INFO ) AS
      ( Select 101, 1, 'Company A', 'Floor desc A 1', 'Section A 1 S1', 'Line A 1 S1 L1' From Dual Union All 
        Select 102, 2, 'Company A', 'Floor desc A 1', 'Section A 1 S2', 'Line A 1 S2 L1' From Dual Union All 
        Select 103, 3, 'Company A', 'Floor desc A 2', 'Section A 1 S2', 'Line A 1 S2 L2' From Dual Union All 
        Select 104, 4, 'Company B', 'Floor desc B 2', 'Section B 2 S4', 'Line B 2 S4 L0' From Dual Union All 
        Select 105, 5, 'Company B', 'Floor desc B 5', 'Section B 5 S1', 'Line B 5 S1 L9' From Dual 
      ),
    attendance_details ( ID, ATT_DATE, EMPNO, IN_TIME, OUT_TIME ) AS 
      ( Select  1001, To_Date('13.06.2024', 'dd.mm.yyyy'), 1, To_Date('13.06.2024 08:57:00', 'dd.mm.yyyy hh24:mi:ss'),  To_Date('13.06.2024 17:03:00', 'dd.mm.yyyy hh24:mi:ss') From Dual Union All 
        Select  1002, To_Date('13.06.2024', 'dd.mm.yyyy'), 2, Null,                                                     To_Date('13.06.2024 16:59:00', 'dd.mm.yyyy hh24:mi:ss') From Dual Union All 
        Select  1003, To_Date('13.06.2024', 'dd.mm.yyyy'), 3, To_Date('13.06.2024 09:03:00', 'dd.mm.yyyy hh24:mi:ss'),  To_Date('13.06.2024 16:50:00', 'dd.mm.yyyy hh24:mi:ss') From Dual Union All 
        Select  1004, To_Date('13.06.2024', 'dd.mm.yyyy'), 4, To_Date('13.06.2024 08:57:00', 'dd.mm.yyyy hh24:mi:ss'),  To_Date('13.06.2024 17:05:00', 'dd.mm.yyyy hh24:mi:ss') From Dual Union All 
        Select  1005, To_Date('13.06.2024', 'dd.mm.yyyy'), 5, To_Date('13.06.2024 08:54:00', 'dd.mm.yyyy hh24:mi:ss'),  To_Date('13.06.2024 16:43:00', 'dd.mm.yyyy hh24:mi:ss') From Dual Union All 
        --
        Select  1006, To_Date('14.06.2024', 'dd.mm.yyyy'), 1, To_Date('14.06.2024 08:51:00', 'dd.mm.yyyy hh24:mi:ss'),  To_Date('14.06.2024 17:00:00', 'dd.mm.yyyy hh24:mi:ss') From Dual Union All 
        Select  1007, To_Date('14.06.2024', 'dd.mm.yyyy'), 3, To_Date('14.06.2024 08:52:00', 'dd.mm.yyyy hh24:mi:ss'),  To_Date('14.06.2024 17:01:00', 'dd.mm.yyyy hh24:mi:ss') From Dual Union All 
        Select  1008, To_Date('14.06.2024', 'dd.mm.yyyy'), 5, To_Date('14.06.2024 08:53:00', 'dd.mm.yyyy hh24:mi:ss'),  To_Date('14.06.2024 17:01:00', 'dd.mm.yyyy hh24:mi:ss') From Dual Union All 
        --
        Select  1009, To_Date('15.06.2024', 'dd.mm.yyyy'), 1, To_Date('15.06.2024 09:00:00', 'dd.mm.yyyy hh24:mi:ss'),  To_Date('15.06.2024 17:00:00', 'dd.mm.yyyy hh24:mi:ss') From Dual Union All 
        Select  1010, To_Date('15.06.2024', 'dd.mm.yyyy'), 2, To_Date('15.06.2024 08:33:00', 'dd.mm.yyyy hh24:mi:ss'),  To_Date('15.06.2024 17:01:00', 'dd.mm.yyyy hh24:mi:ss') From Dual Union All 
        Select  1011, To_Date('15.06.2024', 'dd.mm.yyyy'), 4, To_Date('15.06.2024 09:01:00', 'dd.mm.yyyy hh24:mi:ss'),  To_Date('15.06.2024 17:02:00', 'dd.mm.yyyy hh24:mi:ss') From Dual Union All 
        Select  1012, To_Date('15.06.2024', 'dd.mm.yyyy'), 5, To_Date('15.06.2024 09:31:00', 'dd.mm.yyyy hh24:mi:ss'),  To_Date('15.06.2024 17:03:00', 'dd.mm.yyyy hh24:mi:ss') From Dual Union All 
        --
        Select  1013, To_Date('16.06.2024', 'dd.mm.yyyy'), 1, To_Date('16.06.2024 08:55:00', 'dd.mm.yyyy hh24:mi:ss'),  To_Date('16.06.2024 17:07:00', 'dd.mm.yyyy hh24:mi:ss') From Dual 
      ),

… if you need daily records about employee’s presence create a cte that will generate dates for a period of interest

  dates_times AS 
    ( Select DISTINCT Min(ATT_DATE) Over() + LEVEL - 1 AS ATT_DATE, 
                      Min(ATT_DATE) Over() + LEVEL - 1 + INTERVAL '09:00:00' HOUR TO SECOND AS START_DATE_TIME, 
                      Min(ATT_DATE) Over() + LEVEL - 1 + INTERVAL '17:00:00' HOUR TO SECOND AS END_DATE_TIME
      From attendance_details
      Connect By LEVEL - 1 <= ( Select Max(ATT_DATE) - Min(ATT_DATE) From attendance_details )
    ), 

… and collect all the employee’s data for the period (another cte)

  employees_data AS
    ( SELECT    d.ATT_DATE,  
                --
                ep.EMPNO AS EMPNO, ep.FIRST_NAME AS NAME,
                To_Char(ad.IN_TIME, 'HH24:MI:SS') AS INTIME, TO_CHAR(ad.OUT_TIME, 'HH24:MI:SS') AS OUTTIME,
                --
                Case When ad.IN_TIME Is Null And ad.OUT_TIME Is Null
                     Then 'Not present'
                     When ad.IN_TIME Is Null And ad.OUT_TIME Is Not Null
                     Then 'Check out without check in'
                     When ad.IN_TIME Is Not Null And ad.OUT_TIME Is Null
                     Then 'Check in without check out'
                     When ad.IN_TIME > d.START_DATE_TIME And ad.OUT_TIME < d.END_DATE_TIME
                     Then 'Came late / Left early'
                     When ad.IN_TIME > d.START_DATE_TIME 
                     Then 'Came late'
                     When ad.OUT_TIME < d.END_DATE_TIME
                     Then 'Left early'
                End AS ISSUE,
                --
                eo.COMPANY_NAME AS COMPANY, eo.FLOOR_DESC AS FLOOR,
                eo.SECTION_NAME AS SECTION, eo.LINE_INFO AS LINE
      FROM        emp_personal ep
      INNER JOIN emp_official eo ON( ep.EMPNO = eo.EMPNO )
      INNER JOIN dates_times d ON( 1 = 1 )
      LEFT JOIN attendance_details ad ON( ep.EMPNO = ad.EMPNO And ad.ATT_DATE = d.ATT_DATE )
    )
--    M a i n    S Q L :
--  here you could define different selections/conditions/aggregations/groupings ...
SELECT      * 
FROM        employees_data 
ORDER BY    ATT_DATE, EMPNO
/*        R e s u l t :
ATT_DATE      EMPNO NAME INTIME   OUTTIME  ISSUE                      COMPANY   FLOOR          SECTION        LINE          
-------- ---------- ---- -------- -------- -------------------------- --------- -------------- -------------- --------------
13.06.24          1 John 08:57:00 17:03:00                            Company A Floor desc A 1 Section A 1 S1 Line A 1 S1 L1
13.06.24          2 Jane          16:59:00 Check out without check in Company A Floor desc A 1 Section A 1 S2 Line A 1 S2 L1
13.06.24          3 Kate 09:03:00 16:50:00 Came late / Left early     Company A Floor desc A 2 Section A 1 S2 Line A 1 S2 L2
13.06.24          4 Mike 08:57:00 17:05:00                            Company B Floor desc B 2 Section B 2 S4 Line B 2 S4 L0
13.06.24          5 Anne 08:54:00 16:43:00 Left early                 Company B Floor desc B 5 Section B 5 S1 Line B 5 S1 L9
--
14.06.24          1 John 08:51:00 17:00:00                            Company A Floor desc A 1 Section A 1 S1 Line A 1 S1 L1
14.06.24          2 Jane                   Not present                Company A Floor desc A 1 Section A 1 S2 Line A 1 S2 L1
14.06.24          3 Kate 08:52:00 17:01:00                            Company A Floor desc A 2 Section A 1 S2 Line A 1 S2 L2
14.06.24          4 Mike                   Not present                Company B Floor desc B 2 Section B 2 S4 Line B 2 S4 L0
14.06.24          5 Anne 08:53:00 17:01:00                            Company B Floor desc B 5 Section B 5 S1 Line B 5 S1 L9
--
15.06.24          1 John 09:00:00 17:00:00                            Company A Floor desc A 1 Section A 1 S1 Line A 1 S1 L1
15.06.24          2 Jane 08:33:00 17:01:00                            Company A Floor desc A 1 Section A 1 S2 Line A 1 S2 L1
15.06.24          3 Kate                   Not present                Company A Floor desc A 2 Section A 1 S2 Line A 1 S2 L2
15.06.24          4 Mike 09:01:00 17:02:00 Came late                  Company B Floor desc B 2 Section B 2 S4 Line B 2 S4 L0
15.06.24          5 Anne 09:31:00 17:03:00 Came late                  Company B Floor desc B 5 Section B 5 S1 Line B 5 S1 L9
--
16.06.24          1 John 08:55:00 17:07:00                            Company A Floor desc A 1 Section A 1 S1 Line A 1 S1 L1
16.06.24          2 Jane                   Not present                Company A Floor desc A 1 Section A 1 S2 Line A 1 S2 L1
16.06.24          3 Kate                   Not present                Company A Floor desc A 2 Section A 1 S2 Line A 1 S2 L2
16.06.24          4 Mike                   Not present                Company B Floor desc B 2 Section B 2 S4 Line B 2 S4 L0
16.06.24          5 Anne                   Not present                Company B Floor desc B 5 Section B 5 S1 Line B 5 S1 L9  */

NOTE:
Oracle DATE datatype always contains time component (00:00:00 if not defined like ATT_DATE column in attendance_details cte). You can add/subtract different INTERVAL(s) to a DATE column like START_DATE_TIME/END_DATE_TIME columns in dates_times cte.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật