如何獲得記錄日期的基礎上,我面臨着與date.Actually一些小問題的Grails
我使用Grails 2.3.7,並試圖找到日期範圍的基礎上記錄。假設我想獲得日期爲26-11-2014的所有記錄。
,所以我最後使用這種方法。
String fromDate="2014-12-03";
String toDate="2014-12-04";
SimpleDateFormat df1 = new SimpleDateFormat("yyyy-MM-dd")
Date d1 = df1.parse(fromDate);
Date d2 = df1.parse(toDate);
Order?.executeQuery("select orderDate from Order where orderDate between ? and ? ",[d1,d2]);
而且結果是
[2014-12-03 10:27:23.0, 2014-12-03 10:30:53.0, 2014-12-03 10:32:30.0]
其實4個記錄的2014年3月12日,但我們只得到了3
同樣的事情適用於情節中字到2014-11 -28
,其結果是
[2014-11-27 10:52:56.0, 2014-11-27 13:42:16.0, 2014-11-27 14:44:05.0, 2014-11-27 15:47:36.0,
2014-11-27 15:51:36.0, 2014-11-27 16:10:17.0, 2014-11-27 18:01:08.0, 2014-11-27 18:07:47.0,
2014-11-27 18:30:54.0, 2014-11-27 18:34:06.0, 2014-11-27 18:40:35.0]
其實13條記錄的27-11-2014,但我們只得到了11
請幫助我。
我被困在這裏。
您是否檢查計時? – 2014-12-06 10:33:15
你可以請描述什麼時間是 – 2014-12-06 10:35:29
當你給整個日期格式的子句檢查之間。就像你正在提供'2014-12-04''但它是什麼給這樣或其他什麼'2014-12-04 12:00:00:000' – 2014-12-06 10:43:05