title: Converting Time and Date represented as INT into DateTime structure in LINQ
body: <p>I am currently querying the <code>msdb.dbo.sysjobhistory</code> table to find the status  of the jobs executed today and show them in a browser. The definition of this table looks like this.
  <a href="https://i.stack.imgur.com/1AMUU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1AMUU.png" alt="sysjobshistory Table Definition" /></a></p>
  <p>Here <code>run_date</code> and <code>run_time</code> correspond to the date and time when a particular job was executed both represented as <code>int</code> of course. I am trying to construct a <code>DateTime</code> type from these attributes so that it will be easier to view it in a single column rather than two separate columns.</p>
  <p><strong>Example</strong></p>
  <pre><code>run_date = 20161125
  run_time = 33000
  runStartTime = 2016-11-25 03:30:00 
  </code></pre>
  <p>The viewmodel class I have defined is</p>
  <pre><code>public class ExecutedJobsViewModel
  {
      public string jobName { get; set; }
      public int stepID { get; set; }
      public string stepName { get; set; }
      public string message { get; set; }
      public DateTime runStartTime { get; set; }
      public int runStatus { get; set; }
      public int runDuration { get; set; }
  }
  </code></pre>
  <p>and the code which fetches this data is</p>
  <pre><code> private async Task&lt;List&lt;ExecutedJobsViewModel&gt;&gt; getExecutedJobs()
      {
          using(var context = new SysTableEntity())
          {
              return  await (from job in context.sysjobs
                                        join history in context.sysjobhistories
                                        on job.job_id equals history.job_id
                                        select new ExecutedJobsViewModel
                                        {
                                            jobName = job.name,
                                            message = history.message,
                                            stepID = history.step_id,
                                            stepName = history.step_name,
                                            runStatus = history.run_status,
                                            runDuration = history.run_duration,
                                            runStartTime = // Bind data here
                                        }).ToListAsync();
          }
      }
  </code></pre>
  <p>The only solution I could think of was <code>DbFunctions.CreateDateTime(int? years, int? months, int? days, int? hours, int? minutes, int? seconds)</code> which is too much work given that the <code>int</code> has to be converted to <code>string</code> and then find the sub-string and then convert back to <code>int</code>. Also, handle edge case like <code>33000</code> which are five digits as opposed to time which is represented as six digits number (<code>183000</code>).</p>
  <p>Can you suggest an easier way to achieve this.</p>