duankang8114 2016-09-12 09:46
浏览 30

如何从选定的年份获得所有日期?

My code function is get all value where season from/to in ranges selected years.

I have 2 dropdown for user to select season from/to year . But i have a bug that i can't get value if the tour have both season from/to smaller/larger than selected year . Example:

selected season from/to : 2015 -2016

from          to
2011-05-06    2014-11-12 (not get - work)
2012-04-01    2015-12-31 (get - work)
2015-01-01    2016-08-10 (get - work)
2016-08-11    2018-12-28 (get - work)
2017-01-01    2018-01-01 (not get - work)

2014-01-11    2017-01-01 (I want get this too, because my selected year is 2015-2016)

My code:

$first_day = mktime(0, 0, 0, 1, 1, $params['seasonfrom']) ; //2015-01-01
$first_day = "'".date('Y-m-d',$first_day)."'";

$last_day = mktime(0, 0, 0, 12, 31, $params['seasonto']) ;  //2016-12-31
$last_day = "'".date('Y-m-d',$last_day)."'";

$str1.="(ts.SsnFrom >= {$first_day} AND ts.SsnFrom <={$last_day} 
OR ts.SsnTo >= {$first_day} AND ts.SsnTo <={$last_day})";

CAn anyone give me a solution .Thanks!!

  • 写回答

1条回答 默认 最新

  • douwo8140 2016-09-12 10:06
    关注

    I don't know PHP. Generally suggesting this. This may help you.

    $str1.="({$first_day} BETWEEN ts.SsnFrom AND ts.SsnTo OR {$last_day} BETWEEN ts.SsnFrom AND ts.SsnTo)";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序