检查日期比较? [英] Check the Date comparison ?

查看:59
本文介绍了检查日期比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在比较两个日期时遇到了一个不寻常的问题.Pleas看看。

数据库表



Warranty_renewal_date(日期类型= DATE)

2010-02-12

2010-02-12

2013-06- 11



我的代码在php


I am facing an unusual problem when comparing two dates.Pleas have a look.
Database table

Warranty_renewal_date (Date type= DATE)
2010-02-12
2010-02-12
2013-06-11

My code in php

$sql4="select count(*) as Under_warrenty from machine_details where warranty_renewal_date >=".$current_date;
$result4 = mysql_query($sql4) or die('Query failed: ' . mysql_error());
if ($result4) {
  while ($row4 = mysql_fetch_assoc($result4)) {
      $totlapoll4=$row4["Under_warrenty"];
      
	    }
}

 
$sql5="select count(*) as OutOf_warrenty from machine_details where warranty_renewal_date <=".$current_date ;
$result5 = mysql_query($sql5) or die('Query failed: ' . mysql_error());
if ($result5) {
  while ($row5 = mysql_fetch_assoc($result5)) {
      $totlapoll5=$row5["OutOf_warrenty"];
      
	    }
}





在这种情况下我应该得到什么

$ totlapoll4 = 1

$ totlapoll5 = 2

但是我得到3和0.

有人能说明这里有什么不对吗?

谢谢



In this case what i should get
$totlapoll4=1
$totlapoll5=2
But i am getting 3 and 0.
Can anyone suggest whats wrong here.?
Thanks

推荐答案

sql4 = 从machine_details选择count(*)为Under_warrenty,其中warranty_renewal_date> =


current_date;
current_date;


result4 = mysql_query(
result4 = mysql_query(


这篇关于检查日期比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆