【问题标题】:Need To combine two columns Date and Time in mysql table and find the difference with current date and time需要合并mysql表中的两列日期和时间,并找出与当前日期和时间的差异
【发布时间】:2014-10-08 05:04:12
【问题描述】:

实际上我需要列出从邮件日期和时间开始不超过 24 小时的数据。

我已将邮件日期和邮件时间存储在数据库的 2 个不同列中。

请从我写的以下查询中提供您的有效输入,

      $CTime = strtotime(date('Y-m-d H:i:s'));
      //getting the 24 hours back time
      $Btime = $CTime - 86400;

      $listingInvoice = mysqli_query($conn, "SELECT *, (CONCAT(MailDate, MailTime)) AS MailDT FROM approved WHERE JobStatus='MailedToClient' && MailDT > '$Btime'");

【问题讨论】:

    标签: php mysql sql date time


    【解决方案1】:

    请检查从数据库不同列中获取的日期和时间,并找到该值,即不超过当前时间的 24 小时。

          date_default_timezone_set('Asia/Kolkata');
    
          //getting the current date and time...
          $CTime = date('Y-m-d H:i:s');
    
          //convert to string the current date and time...
          $CSTime = strtotime(date('Y-m-d H:i:s'));
    
          //Minus the 86400(value of 24 Hrs in seconds) in the converted date and time string
          $BStime = $CSTime - 86400;
    
          //getting the value of date and time before 24 Hrs...
          $BTime = date('Y-m-d H:i:s', $BStime);
    
          //Now the query is...
          $reject = mysqli_query($conn, "SELECT * FROM approved WHERE JobStatus='MailToClient' && MailDateTime BETWEEN '$BTime' AND '$CTime'");
          $row = mysqli_num_rows($reject);
          if ($row == '0')
          {
            echo "No Jobs Mails SENT for the Last 24 Hrs";
          }
          else
          {
            ....
          }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-29
      • 2011-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-01
      • 1970-01-01
      相关资源
      最近更新 更多