mardi 13 janvier 2015

How to query data based on a date using Fiscal Year on Sqlite

I'm fixing an android app for a client, and I need to query an sqlite database in order to show a report they need.


The report should only show data for the current fiscal year (begins April-1 ends 31-March). A previous developer did this query:



... WHERE sales_date BETWEEN date('now','localtime','start of year','+3 months') "
+ "AND date('now','localtime','start of year', '+1 year', '+3 months','-1 day') "


This query doesn't work right now since for example in January 2015 it shows data from April 2015 until March 2015, where it should show data from April 2014 until March 2015.


I'm looking for an optmized solution for sqlite since I've found similar answers for other SQL's (Truncate date to fiscal year or Use TO_CHAR function to display the Fiscal Year)


Aucun commentaire:

Enregistrer un commentaire