0
下面的查詢適用於我,直到我應用Where
條件Hour
的屬性Id
= '06/02/2009 12:00CDT'
。如何使用Where子句匹配DateTime條件
我只需要獲取當天日期的最大溫度,而且我無法在日期字段中使用Where
條件。關於我做錯什麼的想法?
Dim document = XDocument.Load("c:\meridian.xml")
Dim wind_gusts = From county In document.Root.Elements("county") Where county.Attribute("name") = "Adams" _
From hour In county.Elements("hour") Where county.Element("hour").Attribute("id").Value = "06/02/2009 13:00CDT" _
From wind_gust In hour.Elements("wind_gust") _
Select CInt(wind_gust) '< DateTime.Parse("06/03/2009") _
'DateTime.Parse(county.Element("hour" + ID).Attribute("id"))
'Dim wind_gust_value = wind_gusts.Max()
For Each m In wind_gusts
Response.Write(m.ToString())
Next
下面是XML:
<?xml version="1.0" ?>
- <forecasts>
<issued>06/02/2009 12:00CDT</issued>
- <county name="Adair">
- <hour id="06/02/2009 12:00CDT">
<air_temp>61</air_temp>
<cloud_cover>overcast</cloud_cover>
<dew_point>59</dew_point>
<precip_prob>90</precip_prob>
<precip_rate>0.12</precip_rate>
<precip_type>rain</precip_type>
<snow_rate>0.0</snow_rate>
<wind_direction>NE</wind_direction>
<wind_speed>12</wind_speed>
<dew_point_confidence>-3/+3</dew_point_confidence>
<road_temp>64</road_temp>
<road_frost_prob>0</road_frost_prob>
<road_potential_evap_rate>429</road_potential_evap_rate>
<road_temp_confidence>-3/+2</road_temp_confidence>
<dew_point_confidence>-3/+3</dew_point_confidence>
<bridge_temp>63</bridge_temp>
<bridge_temp_confidence>-4/+2</bridge_temp_confidence>
<bridge_frost>NO</bridge_frost>
</hour>
+ <hour id="06/02/2009 13:00CDT">
<air_temp>61</air_temp>
<cloud_cover>overcast</cloud_cover>
<dew_point>60</dew_point>
<precip_prob>70</precip_prob>
<precip_rate>0.01</precip_rate>
<precip_type>rain</precip_type>
<snow_rate>0.0</snow_rate>
<wind_direction>ENE</wind_direction>
<wind_speed>10</wind_speed>
<dew_point_confidence>-3/+3</dew_point_confidence>
<road_temp>65</road_temp>
<road_frost_prob>0</road_frost_prob>
<road_potential_evap_rate>411</road_potential_evap_rate>
<road_temp_confidence>-3/+2</road_temp_confidence>
<dew_point_confidence>-3/+3</dew_point_confidence>
<bridge_temp>64</bridge_temp>
<bridge_temp_confidence>-4/+1</bridge_temp_confidence>
<bridge_frost>NO</bridge_frost>
</hour>
+ <hour id="06/02/2009 14:00CDT">
<air_temp>64</air_temp>
<cloud_cover>overcast</cloud_cover>
<dew_point>60</dew_point>
<precip_prob>60</precip_prob>
<precip_rate>trace</precip_rate>
<precip_type>rain</precip_type>
<snow_rate>0.0</snow_rate>
<wind_direction>NE</wind_direction>
<wind_speed>12</wind_speed>
<dew_point_confidence>-3/+3</dew_point_confidence>
<road_temp>65</road_temp>
<road_frost_prob>0</road_frost_prob>
<road_potential_evap_rate>560</road_potential_evap_rate>
<road_temp_confidence>-3/+2</road_temp_confidence>
<dew_point_confidence>-3/+3</dew_point_confidence>
<bridge_temp>65</bridge_temp>
<bridge_temp_confidence>-3/+2</bridge_temp_confidence>
<bridge_frost>NO</bridge_frost>
</hour>
+ <hour id="06/02/2009 15:00CDT">
<air_temp>63</air_temp>
<cloud_cover>overcast</cloud_cover>
<dew_point>59</dew_point>
<precip_prob>50</precip_prob>
<precip_rate>trace</precip_rate>
<precip_type>rain</precip_type>
<snow_rate>0.0</snow_rate>
<wind_direction>NE</wind_direction>
<wind_gust>15</wind_gust>
<wind_speed>12</wind_speed>
<dew_point_confidence>-3/+3</dew_point_confidence>
<road_temp>63</road_temp>
<road_frost_prob>0</road_frost_prob>
<road_potential_evap_rate>397</road_potential_evap_rate>
<road_temp_confidence>-4/+3</road_temp_confidence>
<dew_point_confidence>-3/+3</dew_point_confidence>
<bridge_temp>63</bridge_temp>
<bridge_temp_confidence>-3/+2</bridge_temp_confidence>
<bridge_frost>NO</bridge_frost>
</hour>
+ <hour id="06/02/2009 16:00CDT">
<air_temp>64</air_temp>
<cloud_cover>overcast</cloud_cover>
<dew_point>57</dew_point>
<precip_prob>40</precip_prob>
<precip_rate>trace</precip_rate>
<precip_type>rain</precip_type>
<snow_rate>0.0</snow_rate>
<wind_direction>ENE</wind_direction>
<wind_gust>16</wind_gust>
<wind_speed>11</wind_speed>
<dew_point_confidence>-3/+3</dew_point_confidence>
<road_temp>62</road_temp>
<road_frost_prob>0</road_frost_prob>
<road_potential_evap_rate>400</road_potential_evap_rate>
<road_temp_confidence>-3/+3</road_temp_confidence>
<dew_point_confidence>-3/+3</dew_point_confidence>
<bridge_temp>61</bridge_temp>
<bridge_temp_confidence>-4/+2</bridge_temp_confidence>
<bridge_frost>NO</bridge_frost>
</hour>
+ <hour id="06/02/2009 17:00CDT">
<air_temp>63</air_temp>
<cloud_cover>overcast</cloud_cover>
<dew_point>56</dew_point>
<precip_prob>30</precip_prob>
<precip_rate>trace</precip_rate>
<precip_type>rain</precip_type>
<snow_rate>0.0</snow_rate>
<wind_direction>ENE</wind_direction>
<wind_gust>15</wind_gust>
<wind_speed>10</wind_speed>
<dew_point_confidence>-3/+3</dew_point_confidence>
<road_temp>61</road_temp>
<road_frost_prob>0</road_frost_prob>
<road_potential_evap_rate>344</road_potential_evap_rate>
<road_temp_confidence>-3/+3</road_temp_confidence>
<dew_point_confidence>-3/+3</dew_point_confidence>
<bridge_temp>60</bridge_temp>
<bridge_temp_confidence>-4/+2</bridge_temp_confidence>
<bridge_frost>NO</bridge_frost>
</hour>
+ <hour id="06/02/2009 18:00CDT">
<air_temp>62</air_temp>
<cloud_cover>mostly cloudy</cloud_cover>
<dew_point>54</dew_point>
<precip_prob>20</precip_prob>
<precip_rate>trace</precip_rate>
<precip_type>rain</precip_type>
<snow_rate>0.0</snow_rate>
<wind_direction>ENE</wind_direction>
<wind_speed>10</wind_speed>
<dew_point_confidence>-3/+4</dew_point_confidence>
<road_temp>61</road_temp>
<road_frost_prob>0</road_frost_prob>
<road_potential_evap_rate>530</road_potential_evap_rate>
<road_temp_confidence>-3/+3</road_temp_confidence>
<dew_point_confidence>-3/+4</dew_point_confidence>
<bridge_temp>61</bridge_temp>
<bridge_temp_confidence>-3/+2</bridge_temp_confidence>
<bridge_frost>NO</bridge_frost>
</hour>
+ <hour id="06/02/2009 19:00CDT">
<air_temp>61</air_temp>
<cloud_cover>mostly cloudy</cloud_cover>
<dew_point>52</dew_point>
<precip_prob>10</precip_prob>
<precip_rate>trace</precip_rate>
<precip_type>rain</precip_type>
<snow_rate>0.0</snow_rate>
<wind_direction>ENE</wind_direction>
<wind_speed>7</wind_speed>
<dew_point_confidence>-3/+4</dew_point_confidence>
<road_temp>68</road_temp>
<road_frost_prob>0</road_frost_prob>
<road_potential_evap_rate>959</road_potential_evap_rate>
<road_temp_confidence>-3/+3</road_temp_confidence>
<dew_point_confidence>-3/+4</dew_point_confidence>
<bridge_temp>66</bridge_temp>
<bridge_temp_confidence>-3/+3</bridge_temp_confidence>
<bridge_frost>NO</bridge_frost>
</hour>
+ <hour id="06/02/2009 20:00CDT">
<air_temp>60</air_temp>
<cloud_cover>mostly cloudy</cloud_cover>
<dew_point>51</dew_point>
<precip_prob>10</precip_prob>
<precip_rate>trace</precip_rate>
<precip_type>rain</precip_type>
<snow_rate>0.0</snow_rate>
<wind_direction>ENE</wind_direction>
<wind_speed>5</wind_speed>
<dew_point_confidence>-3/+4</dew_point_confidence>
<road_temp>65</road_temp>
<road_frost_prob>0</road_frost_prob>
<road_potential_evap_rate>495</road_potential_evap_rate>
<road_temp_confidence>-3/+4</road_temp_confidence>
<dew_point_confidence>-3/+4</dew_point_confidence>
<bridge_temp>62</bridge_temp>
<bridge_temp_confidence>-3/+3</bridge_temp_confidence>
<bridge_frost>NO</bridge_frost>
</hour>
+ <hour id="06/02/2009 21:00CDT">
<air_temp>57</air_temp>
<cloud_cover>mostly cloudy</cloud_cover>
<dew_point>51</dew_point>
<precip_prob>0</precip_prob>
<precip_rate>0.00</precip_rate>
<precip_type>none</precip_type>
<snow_rate>0.0</snow_rate>
<wind_direction>NE</wind_direction>
<wind_speed>5</wind_speed>
<dew_point_confidence>-3/+4</dew_point_confidence>
<road_temp>62</road_temp>
<road_frost_prob>0</road_frost_prob>
<road_potential_evap_rate>339</road_potential_evap_rate>
<road_temp_confidence>-3/+4</road_temp_confidence>
<dew_point_confidence>-3/+4</dew_point_confidence>
<bridge_temp>59</bridge_temp>
<bridge_temp_confidence>-3/+3</bridge_temp_confidence>
<bridge_frost>NO</bridge_frost>
</hour>
+ <hour id="06/02/2009 22:00CDT">
<air_temp>56</air_temp>
<cloud_cover>mostly cloudy</cloud_cover>
<dew_point>51</dew_point>
<precip_prob>0</precip_prob>
<precip_rate>0.00</precip_rate>
<precip_type>none</precip_type>
<snow_rate>0.0</snow_rate>
<wind_direction>ENE</wind_direction>
<wind_speed>5</wind_speed>
<dew_point_confidence>-3/+4</dew_point_confidence>
<road_temp>60</road_temp>
<road_frost_prob>0</road_frost_prob>
<road_potential_evap_rate>309</road_potential_evap_rate>
<road_temp_confidence>-3/+4</road_temp_confidence>
<dew_point_confidence>-3/+4</dew_point_confidence>
<bridge_temp>58</bridge_temp>
<bridge_temp_confidence>-3/+3</bridge_temp_confidence>
<bridge_frost>NO</bridge_frost>
</hour>
這是爲什麼社會維基?如果他們無法獲得代表,人們不會想要幫助你解決問題。 – 2009-08-26 21:40:05
如果你想要max temp,爲什麼要查詢wind_gust? – Cheeso 2009-08-26 21:58:38