<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: QueryLayer help with DateTime field in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/querylayer-help-with-datetime-field/m-p/1324786#M72685</link>
    <description>&lt;P&gt;Hi Alfred,&lt;/P&gt;&lt;P&gt;I was working on this today and what seems to be working is this.&amp;nbsp; It's not really that different from the first one I tried, but today it's working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;select GISWRKS1.works.WAT_ControlValve_evw.*
FROM GISWRKS1.works.WAT_ControlValve_evw
WHERE FACILITYID NOT IN (
SELECT FACILITYID FROM GISWRKS1.works.INSPECTIONS_VALVE_INSPECTION
WHERE DATEPART(year, GISWRKS1.works.INSPECTIONS_VALVE_INSPECTION.INSP_DATE) &amp;gt;= 2022)&lt;/LI-CODE&gt;&lt;P&gt;This gives me all valves not done in 2022 (or later), which is what I am looking for.&amp;nbsp; Maybe just scrapping everything and starting from scratch is what helped??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Sep 2023 15:32:57 GMT</pubDate>
    <dc:creator>BrianBulla</dc:creator>
    <dc:date>2023-09-01T15:32:57Z</dc:date>
    <item>
      <title>QueryLayer help with DateTime field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/querylayer-help-with-datetime-field/m-p/1324518#M72656</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to use the following SQL statment in the "Edit Query Layer" dialog, but it seems to be getting hung-up on the "year" part of the query where I am just looking for rows that have an INSP_DATE year of 2022.&amp;nbsp; I don't think this "year" functionality exists in the query tool, so I am just wondering on an alternative method.&lt;/P&gt;&lt;P&gt;I've tried every SQL trick I can think of, but cannot get this to work.&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;select GISWRKS1.works.WAT_ControlValve_evw.*
FROM GISWRKS1.works.WAT_ControlValve_evw
WHERE FACILITYID NOT IN (
SELECT FACILITYID FROM GISWRKS1.works.INSPECTIONS_VALVE_INSPECTION
WHERE DATEPART(year, INSP_DATE) = 2022)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This should exclude all valves that had in inspection done in 2022, but it always shows all valves.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2023 19:14:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/querylayer-help-with-datetime-field/m-p/1324518#M72656</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2023-08-31T19:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: QueryLayer help with DateTime field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/querylayer-help-with-datetime-field/m-p/1324766#M72681</link>
      <description>&lt;P&gt;Try simplifying it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;select * from database.owner.Monitoring_tb
WHERE DATEPART(year, Mon_Date) = 2020&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This worked fine for me.&lt;/P&gt;&lt;P&gt;Edit: Oh whoops, didn't realize you were looking between two tables. Will revise my answer shortly.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 14:47:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/querylayer-help-with-datetime-field/m-p/1324766#M72681</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-09-01T14:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: QueryLayer help with DateTime field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/querylayer-help-with-datetime-field/m-p/1324774#M72682</link>
      <description>&lt;P&gt;So, I don't have really good data to test this on, since the points used here get inspected more than once.&lt;/P&gt;&lt;P&gt;This shoooould work if the monitoring table has just one record for each valve?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;select 
t1.OBJECTID,
t1.Nest_ID
 from db.owner.LOCATIONS_PT t1
INNER JOIN 
db.owner.MONITORING_TB t2
ON t1.Nest_ID = t2.Nest_ID
WHERE DATEPART(year, t2.NestMon_Date) !=2022&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the most recent record:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;SELECT 
t1.OBJECTID,
t1.Nest_ID,
t2.NestMon_Date
FROM db.owner.Locations_pt t1 
  INNER JOIN (
    SELECT MIN(OBJECTID) as OID, 
    Nest_ID, 
    MAX(NestMon_Date) as MaxDate   
    FROM db.owner.Monitoring_tb   
    GROUP BY Nest_ID ) MaxDates ON t1.Nest_ID = MaxDates.Nest_ID 
    INNER JOIN db.owner.Monitoring_tb t2 
	ON MaxDates.Nest_ID = t2.Nest_ID 
		AND MaxDates.MaxDate = t2.NestMon_Date 
		AND MaxDates.OID = t2.OBJECTID
WHERE datepart(year,t2.NestMon_Date) !=2022&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 15:03:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/querylayer-help-with-datetime-field/m-p/1324774#M72682</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-09-01T15:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: QueryLayer help with DateTime field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/querylayer-help-with-datetime-field/m-p/1324786#M72685</link>
      <description>&lt;P&gt;Hi Alfred,&lt;/P&gt;&lt;P&gt;I was working on this today and what seems to be working is this.&amp;nbsp; It's not really that different from the first one I tried, but today it's working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;select GISWRKS1.works.WAT_ControlValve_evw.*
FROM GISWRKS1.works.WAT_ControlValve_evw
WHERE FACILITYID NOT IN (
SELECT FACILITYID FROM GISWRKS1.works.INSPECTIONS_VALVE_INSPECTION
WHERE DATEPART(year, GISWRKS1.works.INSPECTIONS_VALVE_INSPECTION.INSP_DATE) &amp;gt;= 2022)&lt;/LI-CODE&gt;&lt;P&gt;This gives me all valves not done in 2022 (or later), which is what I am looking for.&amp;nbsp; Maybe just scrapping everything and starting from scratch is what helped??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 15:32:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/querylayer-help-with-datetime-field/m-p/1324786#M72685</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2023-09-01T15:32:57Z</dc:date>
    </item>
  </channel>
</rss>

