这是我的代码和我的问题。当我运行 SQL 查询时,它不仅显示当前年份,而且显示前一年(2018 年),它显示(对于当前月份,我正在写这个),我认为我转换日期的方式有问题?任何帮助,将不胜感激。 <?$fdaymonth = (new DateTime('first day of this month'))->format('m/d/Y');$ldaymonth = (new DateTime('last day of this month'))->format('m/d/Y');$currmonthname = Date('F');?><hr /><p class="pull-left txt-color-blueLight">Marked in system as sold in <?=$currmonthname;?>: <? $query = "SELECT source,count(*) as totalFROM appsWHERE date_sold BETWEEN '" . $fdaymonth . "' and '" . $ldaymonth . "'";$result = mysqli_query($conn,$query) or die(mysqli_error($conn)); if (mysqli_num_rows($result)== 0) echo "<strong>Error</strong>"; // Print out result while($row = mysqli_fetch_array($result)){ echo "<b class=\"badge bg-color-greenLight\">" . $row['total'] . "</b>";}?></p>
2 回答
慕沐林林
TA贡献2016条经验 获得超9个赞
我最终添加了一个新列并将 TEXT 列日期转换为 DATE 列以便更轻松地转换。date_sold 列是 TEXT 列,但以 DD/MM/YYYY 格式保存实际日期,这会导致冲突。现在它是一个 DATE 格式的 SQL 列,我可以得到我想要的结果。感谢大家。
- 2 回答
- 0 关注
- 488 浏览
添加回答
举报
0/150
提交
取消
