title: How to Calculate the In Time and Out Time for Attendance of 3rd shift
body: <p>I am developing a web application for attendance controlling. I am getting data from <code>ZKT</code> Machine through <code>.Net</code> <code>API.</code> in shape of array. 
  From this API I am not getting any flag for <code>In</code> or <code>Out Time</code>. So I adopt the technique that first punching time will be in <code>In Time</code>
   and the time which I am getting in last will <code>Out Time</code> in a particular date. Because I may get more then 2 punching time in a particular day.</p>
  
  <p>Now I have the scenario for 3rd shift which will start 10PM and will end 6AM next day. Now I am thinking how I can get the <code>Out Time</code> in this case. The attendance date will be the date of <code>In Time</code> of a day. For example if the employee comes 05/03/2018 at 10PM the 5th of March will be the attendance date. </p>
  
  <p>Please help to tackle this problem. </p>
  
  <p>Data input format from machine</p>
  
  <pre><code>2017-06-16 09:00:00.000 I0495
  2017-06-16 10:30:00.000 I0495
  2017-06-16 13:00:00.000 I0495
  2017-06-16 17:05:00.000 I0495
  
  2017-06-16 09:15:00.000 I0603
  2017-06-16 11:30:00.000 I0603
  2017-06-16 00:00:00.000 I0603
  2017-06-16 01:30:00.000 I0603
  2017-06-16 17:10:00.000 I0603
  </code></pre>
  
  <p>here is code which is handling day time shift</p>
  
  <pre><code>while (axCZKEM1.SSR_GetGeneralLogData(iMachineNumber, out sdwEnrollNumber, out idwVerifyMode,
  out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode))//get records from the memory
  {
      if (idwYear.ToString() == DtpAtt.Value.Year.ToString() &amp;&amp; idwMonth.ToString() == DtpAtt.Value.Month.ToString() &amp;&amp; idwDay.ToString() == DtpAtt.Value.Day.ToString())
      {
          iGLCount++;
          lvLogs.Items.Add(iGLCount.ToString());
          lvLogs.Items[iIndex].SubItems.Add(sdwEnrollNumber);//modify by Darcy on Nov.26 2009
          lvLogs.Items[iIndex].SubItems.Add(idwVerifyMode.ToString());
          lvLogs.Items[iIndex].SubItems.Add(idwInOutMode.ToString());
          lvLogs.Items[iIndex].SubItems.Add(idwYear.ToString() + "-" + idwMonth.ToString() + "-" + idwDay.ToString() + " " + idwHour.ToString() + ":" + idwMinute.ToString() + ":" + idwSecond.ToString());
          lvLogs.Items[iIndex].SubItems.Add(idwWorkcode.ToString());
  
          var id = Convert.ToInt32(mdl.GetRecord("id", "atndnce", "attendance_id='" + sdwEnrollNumber + "' and attendance_date='" + DtpAtt.Value.ToString("yyyy-MM-dd") + "'"));
          if (id &gt; 0)
          {
              var time = mdl.GetRecord("in_time", "atndnce", "attendance_id='" + sdwEnrollNumber + "' and attendance_date='" + idwYear.ToString() + "-" + idwMonth.ToString() + "-" + idwDay.ToString() + "'");
              mdl.UpdateRecord("atndnce", " duty_hours = '" + TxtHours.Text.ToString() + "', out_time='" + idwHour.ToString() + ":" + idwMinute.ToString() + ":" + idwSecond.ToString() + "'", "id = " + id.ToString());
          }
          else
              mdl.InsertRecord("atndnce", "attendance_id,attendance_date,in_time,posted,duty_hours,machine_id", "'" + sdwEnrollNumber + "','" + idwYear.ToString() + "-" + idwMonth.ToString() + "-" + idwDay.ToString() + "','" + idwHour.ToString() + ":" + idwMinute.ToString() + ":" + idwSecond.ToString() + "',0 ,'" + TxtHours.Text.ToString() + "','" + CmbStation.SelectedValue + "'");
          iIndex++;
      }
  }
  </code></pre>