<?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: SelectLayerByAttribute_management issue, need help in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711865#M55187</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you considered using if/elif/else statements in the CalculateField_management code block instead of the SelectLayerByAttribute_management function?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.CalculateField_management(layer, "Project_STATUS", expression="update(!ACTUAL_DESIGN_START!, !ACTUAL_NTP!)", "PYTHON", """def update(design, NTP):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if design == 1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Design"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; elif NTP == 1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Construction"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;/P&gt;&lt;P&gt;""")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Jan 2016 01:20:42 GMT</pubDate>
    <dc:creator>MichelleTotman</dc:creator>
    <dc:date>2016-01-28T01:20:42Z</dc:date>
    <item>
      <title>SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711854#M55176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Trying to work my way through a PGDB and update the field PROJECT_STATUS depending on data in other fields.&amp;nbsp; My problem seems to be in the query portion of theelectLayerByAttribute.&amp;nbsp; I've tried to many iterations of this.&amp;nbsp; Eventually I wanted to update this data directly in SDE on our SQL Server but I think I can figure that out once I get this.&amp;nbsp; Thank you..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BELOW IS A WORKING SCRIPT.&amp;nbsp; Thank you all.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&lt;SPAN style="font-family: Consolas;"&gt;#### updated script&lt;/SPAN&gt;
&lt;SPAN style="font-family: Consolas;"&gt;# Import arcpy module
import arcpy, time, sys
from arcpy import env
&lt;/SPAN&gt;
&lt;SPAN style="font-family: Consolas;"&gt;env.overwriteOutput = True
env.workspace = "Database Connections//GISSDE.RTC.sde"&lt;/SPAN&gt;
&lt;SPAN style="font-family: Consolas;"&gt;arcpy.MakeFeatureLayer_management("RTC.GISSDE.MPO_CMWG_L_TEST","cmwg_lyr")&lt;/SPAN&gt;
&lt;SPAN style="font-family: Consolas;"&gt;arcpy.SelectLayerByAttribute_management("cmwg_lyr", "NEW_SELECTION", "")
arcpy.CalculateField_management("cmwg_lyr", "PROJECT_STATUS", "\"\"", "VB", "")&lt;/SPAN&gt;
&lt;SPAN style="font-family: Consolas;"&gt;arcpy.SelectLayerByAttribute_management("cmwg_lyr", "NEW_SELECTION", "[ACTUAL_DESIGN_START] = 1")
arcpy.CalculateField_management("cmwg_lyr", "PROJECT_STATUS", "\"DESIGN\"", "VB", "")&lt;/SPAN&gt;
&lt;SPAN style="font-family: Consolas;"&gt;arcpy.SelectLayerByAttribute_management("cmwg_lyr", "NEW_SELECTION", "[ACTUAL_NTP] = 1")
arcpy.CalculateField_management("cmwg_lyr", "PROJECT_STATUS", "\"CONSTRUCTION\"", "VB", "")&lt;/SPAN&gt;
&lt;SPAN style="font-family: Consolas;"&gt;arcpy.SelectLayerByAttribute_management("cmwg_lyr", "NEW_SELECTION", "[ACTUAL_SUBSTANTIAL_COMPLETION] &amp;lt;= CURRENT_TIMESTAMP")
arcpy.CalculateField_management("cmwg_lyr", "PROJECT_STATUS", "\"SUBSTANTIAL COMPLETION\"", "VB", "")&lt;/SPAN&gt;
&lt;SPAN style="font-family: Consolas;"&gt;arcpy.SelectLayerByAttribute_management("cmwg_lyr", "NEW_SELECTION", "RTC_PROJECT_CLOSED &amp;lt;= CURRENT_TIMESTAMP")
arcpy.CalculateField_management("cmwg_lyr", "PROJECT_STATUS", "\"CLOSED\"", "VB", "")&lt;/SPAN&gt;
&lt;SPAN style="font-family: Consolas;"&gt;arcpy.SelectLayerByAttribute_management("cmwg_lyr", "NEW_SELECTION", "[PROJECT_STATUS] IS NULL OR [PROJECT_STATUS] = ''")
arcpy.CalculateField_management("cmwg_lyr", "PROJECT_STATUS", "\"PLANNED\"", "VB", "")&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:30:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711854#M55176</guid>
      <dc:creator>JohnRitsko</dc:creator>
      <dc:date>2021-12-12T06:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711855#M55177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to use &lt;A href="http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/make-feature-layer.htm" title="http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/make-feature-layer.htm"&gt;Make Feature Layer—Help | ArcGIS for Desktop&lt;/A&gt; before you can select by attribute.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 00:07:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711855#M55177</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-01-28T00:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711856#M55178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the first example in the &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/Select_Layer_By_Attribute/001700000071000000/"&gt;SelectLayerByAttribute&lt;/A&gt; help page, which uses MakeFeatureLayer, as Wes says, and the correct syntax for PGDB feature classes (brackets, not quotes).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 00:13:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711856#M55178</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-01-28T00:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711857#M55179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can also do your selection with Make Feature Layer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 00:18:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711857#M55179</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-01-28T00:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711858#M55180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Darren, if I'm trying to do this in SDE do I utilize quotes then?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 00:30:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711858#M55180</guid>
      <dc:creator>JohnRitsko</dc:creator>
      <dc:date>2016-01-28T00:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711859#M55181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, but I'm still a bit lost here with this function.&amp;nbsp; I'm wanting to do these in order as some will overwrite ones before.&amp;nbsp; Am I safe in saying that the makefeaturelayer will simply just create a singular new feature layer?&amp;nbsp; I only want to update records in this feature class.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 00:34:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711859#M55181</guid>
      <dc:creator>JohnRitsko</dc:creator>
      <dc:date>2016-01-28T00:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711860#M55182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure. You can look into it &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/Building_a_query_expression/00s50000002t000000/"&gt;here &lt;/A&gt;and &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s500000033000000"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Luckily, no matter what you use, you can get it right by using &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/AddFieldDelimiters/03q300000091000000/"&gt;AddFieldDelimiters()&lt;/A&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 00:38:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711860#M55182</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-01-28T00:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711861#M55183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
from arcpy import env
env.overwriteOutput = True
env.workspace = r"C://test//CMWGp.mdb"
arcpy.MakeFeatureLayer_management("C://test//CMWGp.mdb//CMWG_L_TEST","cmwg_lyr")
arcpy.SelectLayerByAttribute_management("cmwg_lyr", "NEW_SELECTION", "[ACTUAL_DESIGN_START] ='1'")
arcpy.CalculateField_management("cmwg_lyr", "PROJECT_STATUS", "\"DESIGN\"", "VB", "")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is what I tried and no luck.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:\Users\ritskoj\Desktop\cmwgUpdates.py", line 19, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management("cmwg_lyr", "NEW_SELECTION", "[ACTUAL_DESIGN_START] ='1'")&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 6688, in SelectLayerByAttribute&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 000358: Invalid expression&lt;/P&gt;&lt;P&gt;Failed to execute (SelectLayerByAttribute).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:30:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711861#M55183</guid>
      <dc:creator>JohnRitsko</dc:creator>
      <dc:date>2021-12-12T06:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711862#M55184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is the same as adding a layer to arcmap. You are still updating the feature class,but it will allow you to select by attributes or select by location as a feature layer not as a feature class.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 00:42:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711862#M55184</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-01-28T00:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711863#M55185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the field type for [ACTUAL_DESIGN_START?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 00:46:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711863#M55185</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-01-28T00:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711864#M55186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Short Integer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The others are Date and Text.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 00:49:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711864#M55186</guid>
      <dc:creator>JohnRitsko</dc:creator>
      <dc:date>2016-01-28T00:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711865#M55187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you considered using if/elif/else statements in the CalculateField_management code block instead of the SelectLayerByAttribute_management function?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.CalculateField_management(layer, "Project_STATUS", expression="update(!ACTUAL_DESIGN_START!, !ACTUAL_NTP!)", "PYTHON", """def update(design, NTP):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if design == 1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Design"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; elif NTP == 1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Construction"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;/P&gt;&lt;P&gt;""")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 01:20:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711865#M55187</guid>
      <dc:creator>MichelleTotman</dc:creator>
      <dc:date>2016-01-28T01:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711866#M55188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Remove the quotes around number values. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 01:50:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711866#M55188</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-01-28T01:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711867#M55189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You sir have fixed my issue.&amp;nbsp; Thank you.&amp;nbsp; Both you and Wes Miller have been very helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Now I do have one other questions.&amp;nbsp; How do I deal with a date fields?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 14:44:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711867#M55189</guid>
      <dc:creator>JohnRitsko</dc:creator>
      <dc:date>2016-01-28T14:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711868#M55190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michelle,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Yeah, I wanted to deal with this in and if elif situation but couldn't get my expressions working right.&amp;nbsp; Now that I've got things rolling and once I figure out how to query a date I'll be set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On that note, if you know how to ask for the current date and check against that I would be very grateful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all for the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 14:46:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711868#M55190</guid>
      <dc:creator>JohnRitsko</dc:creator>
      <dc:date>2016-01-28T14:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711869#M55191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Things are progressing well.&amp;nbsp; The main answer to my question has been answered but I'm having issues with this last bit in regards to the date.&amp;nbsp; I can't seem to query against the data, Invalid Expression.&amp;nbsp; Any thoughts?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.SelectLayerByAttribute_management("cmwg_lyr", "NEW_SELECTION", "[ACTUAL_SUBSTANTIAL_COMPLETION] &amp;lt;= CURRENT_DATE")
arcpy.CalculateField_management("cmwg_lyr", "PROJECT_STATUS", "\"SUBSTANTIAL COMPLETION\"", "VB", "")&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:30:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711869#M55191</guid>
      <dc:creator>JohnRitsko</dc:creator>
      <dc:date>2021-12-12T06:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711870#M55192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is CURRENT_DATE?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 16:09:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711870#M55192</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-01-28T16:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711871#M55193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CURRENT_DATE is me trying to get the current date to compare against.&amp;nbsp; I don't yet have a way of getting the Current Date in there.&amp;nbsp; I'm now working on updating my data in SDE.&amp;nbsp; The field that I'm trying to create the query against is a DATE field so I need to compare todays date against that field.&amp;nbsp; Trying to figure out how to get todays date in python to match what is in SDE in SQL Server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note: in SQL Server we store the dates that I require my compare against as datetime2 fields.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This is how the present value is displayed. &lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: Consolas;"&gt;&lt;STRONG&gt;2016-01-28 08:31:18.568000&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In SQL Server the date field (ACTUAL_SUBSTANTIAL_COMPLETION)&lt;/P&gt;&lt;P&gt;shows 2015-09-25 00:00:00.000&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: Consolas;"&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;STRONG&gt;&lt;STRONG&gt;present = datetime.now()
'{:%Y-%m-%d %H:%M:%S}'.format(present)
&lt;/STRONG&gt;&lt;/STRONG&gt;
&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;where = "[ACTUAL_SUBSTANTIAL_COMPLETION] &amp;lt;= " + str(present)
arcpy.SelectLayerByAttribute_management("cmwg_lyr", "NEW_SELECTION", where)
arcpy.CalculateField_management("cmwg_lyr", "PROJECT_STATUS", "\"SUBSTANTIAL COMPLETION\"", "VB", "")&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:30:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711871#M55193</guid>
      <dc:creator>JohnRitsko</dc:creator>
      <dc:date>2021-12-12T06:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711872#M55194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This should get you the datetime, but you may need to go thru some testing to get it just right (trust me, dates are just loads of fun to deal with).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import datetime
current_date = datetime.datetime.now()
print current_date&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CURRENT_DATE in SQL?&amp;nbsp; DO you mean CURRENT_TIMESTAMP?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:30:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711872#M55194</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-12T06:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management issue, need help</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711873#M55195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah, it's driving me nuts to be honest.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Current_DATE that I mentioned was me simply trying to figure out the current date in a format that would allow my query to work. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In SDE I have a feature class that I'm trying to access the ACTUAL_SUBSTANTIAL_COMPLETION field which is a date field.&amp;nbsp; I want to compare that field against todays date and if it's &amp;lt;= to today then I can calculate a value into the PROJECT_STATUS field.&amp;nbsp; I hope this helps get you a better understanding of what I'm doing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I create the query it continues to tell me invalid expression.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 17:30:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-issue-need-help/m-p/711873#M55195</guid>
      <dc:creator>JohnRitsko</dc:creator>
      <dc:date>2016-01-28T17:30:22Z</dc:date>
    </item>
  </channel>
</rss>

