AnsweredAssumed Answered

Query using TimeExtent and a date picker

Question asked by mrogers83 on Mar 11, 2014
I have brought in a date picker using datetimepicker.js. I want to query a feature layer by the date brought in using the date picker. Even though I have chosen the date using the date picker, the information coming into the grid is still for a different date than the one I chose. If someone could help me accomplish this, I would appreciate it. For now, it is the last item that I need to accomplish the viewer that I am trying to build. The entire code for the project is on jsfiddle here:http://jsfiddle.net/mrogers83/Hz59f/5/

The specific area that I am looking at is here:
function execute(){  var queryTask = new QueryTask(window.historicalUrl);  var query = new Query();  query.text = dom.byId("mydropdown").value;  query.timeExtent = new TimeExtent(dom.byId("date").value);  query.returnGeometry = true;  query.outFields = window.historicalOutFields;  queryTask.execute(query, function (results) {   var data = [];   var data = array.map(results.features, function (feature) {    return {     "Vehicleid": feature.attributes[window.historicalOutFields[0]],     "Velocity": feature.attributes[window.historicalOutFields[1]],     "StreetName": feature.attributes[window.historicalOutFields[4]],     "TimeStamp": feature.attributes[window.historicalOutFields[3]]    }   });   var memStore = new Memory ({data:data});   window.grid3.set("store", memStore);  }); };  <div id="rightPane" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'right'">  Unit ID:  <select id = "mydropdown">  <option value = "239-2277793">PD080</option>  <option value = "239-2277794">PD168</option>  <option value = "239-2277783">PD169</option>  <option value = "239-2277773">PD170</option>  <option value = "239-3983647">PD171</option>  <option value = "239-2277790">PD172</option>  <option value = "239-2277795">PD878</option>  <option value = "239-2277772">PD879</option>  <option value = "239-2277785">PD880</option>  <option value = "239-2277788">PD881</option>  <option value = "239-2277791">PD882</option>  <option value = "239-2277798">PD884</option>  <option value = "239-2277775">PD977</option>  <option value = "239-2277789">PD978</option>  <option value = "239-2277776">PD979</option>  <option value = "239-2277778">PD980</option>  <option value = "239-2277780">PD981</option>  <option value = "239-2277787">PD3018</option>  <option value = "239-2939847">PD3019</option>  <option value = "239-2277786">PD3020</option>  <option value = "239-2277781">PD3021</option>  <option value = "239-2277802">PD3022</option>  </select>  Date: <input id="date" type="text" size="18"><a href="javascript:NewCal('date', 'mmddyyyy')"><img src="images/cal.gif" width:"16" height="16" border="0"></a>  <div>  <input id ="execute" type="button" value="Get Details">  <input id ="mapshow" type="button" value="Show on Map">  <input id ="clear" type="button" value="Clear History">  </div>  <div id="grid3"></div> </div> 


Again, any help is greatly appreciated!

Michelle

Edit: I figured out what my issue was. We did not have time enabled on the service, therefore I could not query the time extent. We enabled the time on the service and changed the query to: query.timeExtent = new TimeExtent(new Date(dom.byId("date").value));

Outcomes