Here's how it could be solved, though due to Google Docs Spreadsheet API's poor documentation the solution has taken some time, and looks a bit ugly.
As I've tried it with Java, I'll illustrate it with Java code, but it could be easily reproduced with other programming tools.
As date is represented in Google spreadsheets as numeric value symbolizing the number of days after some "zero" date, the query should look like:
query.setSpreadsheetQuery("date1 > " + fromDateNumericValue + " and date2 < " + toDateNumericValue);
where fromDateNumericValue and toDateNumericValue could be calculated with the following method:
public static int getDateNumericValue(Date date) throws ParseException {
long zeroTime = new SimpleDateFormat("yyyy-MM-dd").parse("1899-12-30").getTime();
long time = date.getTime();
double numberOfDays = (double)(time - zeroTime ) / (double)(24 * 60 * 60 * 1000);
return (int)(Utils.round(numberOfDays, 0));
}
...
fromDateNumericValue = getDateNumericValue(new SimpleDateFormat("MM.dd.yyyy").parse("02.10.2010"));
toDateNumericValue = getDateNumericValue(new SimpleDateFormat("MM.dd.yyyy").parse("11.10.2011"));
Комментариев нет:
Отправить комментарий