2012-07-13 26 views
-2

我在2012-02-15 00:02:03格式中存儲了從sqlite數據庫中的最新和最新版本。現在如何檢索這個。我試着用下面的查詢..我哪裏出錯了。在android中獲取db的日期值

select category,sum(amount) from inbox where strftime(currentdate) > strftime(fastdate) 

它顯示錯誤。任何人都可以幫我解決這個問題

+0

什麼樣的錯誤?請明確點。 – 2012-07-13 12:50:21

+0

android.database.sqlite.SQLiteException:語法錯誤: – 2012-07-13 12:54:35

+0

android.database.sqlite.SQLiteException:接近「00」:語法錯誤:編譯時:選擇類別,從收件箱中的總和(金額)其中accno ='2754'和類別='未分類'和strftime(2012-7-13 00:00:00)> strftime(2011-7-13 00:00:00) – 2012-07-13 12:58:03

回答

1

你沒有正確使用strftime。

strftime('format', 'time')

這需要一個格式和時間的字符串版本。你沒有把時間放在一個字符串中。

你可以看到所有不同的格式和一些例子here

您的比較應該是這樣的......

的strftime( '%s' 的, '的currentdate')>的strftime( '%s' 的, 'fastdate')

+0

如果我給沒有日期它將工作。 – 2012-07-13 13:02:56

+0

找到了你的答案。 – 2012-07-13 13:08:42

+0

對不起,我犯了錯誤。我這樣寫。這個查詢正在工作select category,sum(amount)from inbox where accno ='0004'and category ='Un Categorized'and strftime(fromtime)> date('now',' - 1 year') – 2012-07-13 13:10:07