68045

Date query with the current date between two date_time columns

I have a fusion table with two date_time columns. The fist one is the start date (Startdatum) and in the other column is the end date (Einddatum).

I want to do a query with the current date, and only show the KML-lines on a map where the current date lies between the start and end date.

I tried to use the code below to create a string with a date format:

var time_date = new Date(); var day = time_date.getDate(); var month = time_date.getMonth()+1; var year = time_date.getFullYear(); var date = (year+"."+month+"."+day);

To show the KML-lines on the map I tried to use the following code:

layer = new google.maps.FusionTablesLayer({ map: map, heatmap: { enabled: false }, query: { select: "col2", from: "1mOMP1seJq4FdiNTugsfylZaJc8sKcSlfJKUuTJjv", where: "'Startdatum' <= date AND 'Einddatum' >= date" }, options: { styleId: 2, templateId: 2 } });

Unfortunatly the map shows all the KMS-lines regardless what date is in one of the columns.

What am I doing wrong?

Answer1:

<ol> <li>

the where-clause is wrong, it has to be

where: "Startdatum <= '"+date+"' AND Einddatum >= '"+date+"'" </li> <li>

the date-format seems to be wrong. Although the used format yyyy.MM.dd is defined in the documentation, it doesn't work. The format yyyy-MM-dd currently works for me(but it's not defined in the documentation).

var date = (year+"-"+month+"-"+day);

(in case that day and month be less than 10 they wouldn't match the pattern, but that doesn't seem to be an issue)

</li> </ol>

Beyond that: when you fix these 2 mentioned parts it currently works(for me), but I've tried it a couple of hours ago and got unstable results.

Recommend

  • Changing date format in Pentaho using javascripting
  • Passing variable into xp_cmdshell
  • dc.js / crossfilter dimensions (year / week)
  • MySql - get days remaining
  • Returning this from a constructor function in JS
  • What is the use of a session store?
  • How to get the date of next specified day of week
  • Android Studio 1.3 RC3. Google Play services out of date. Requires 7571000 but found 6774470
  • android google indoor map
  • Android Google Maps API v2 start navigation
  • Insert new calendar with SyncAdapter- Calendar API Android
  • How can I enlarge video fullscreen without the affected interface project in as3?
  • Why querying a date BC is changed to AD in Java?
  • Seeking advice on Jetty HttpClient Hang
  • Illegal mix of collations for operation for date/time comparison
  • Release, debug version and Authorization Google?
  • Font Awesome Showing Box instead of Icons
  • Adding custom controls to a full screen movie
  • Google cloud sdk not working when python points python3
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • AT Commands to Send SMS not working in Windows 8.1
  • Comma separated Values
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • How to delete a row from a dynamic generate table using jquery?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Error creating VM instance in Google Compute Engine
  • Acquiring multiple attributes from .xml file in c#
  • using HTMLImports.whenReady not working in chrome
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Authorize attributes not working in MVC 4
  • apache spark aggregate function using min value
  • How can I remove ASP.NET Designer.cs files?
  • Is it possible to post an object from jquery to bottle.py?
  • EntityFramework adding new object to nested object collection
  • Sorting a 2D array using the second column C++
  • Android Heatmap on canvas or ImageView
  • Python/Django TangoWithDjango Models and Databases
  • java string with new operator and a literal