這是我的代碼和我的問題。當我運行 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 格式保存實際日期,這會導致沖突?,F在它是一個 DATE 格式的 SQL 列,我可以得到我想要的結果。感謝大家。
- 2 回答
- 0 關注
- 432 瀏覽
添加回答
舉報
0/150
提交
取消