3

I have a script that runs, that takes the current date and puts into a variable, which is then used to calculate the date field for the Feature class. Further in the script, the updated data is loaded into the live SDE feature class.

The old data get deleted with the following task.

1 - Make Feature layer, where the date field is not equal to the date variable.

2 - Delete these features.

My problem is that the to create feature layer is empty as i can't get the syntax right.

I have tried the following

gp.MakeFeatureLayer(myOutputConnexion + os.sep + "SY_PLN_MON_INFO.LLPG_POINTS","OLD_LLPG_POINTS","GIS_TIMESTAMP <> TO_DATE('" + ExactScriptTime + "00:00:00' ,'YYYY/MM/DD HH24:MI:SS')")

and

    gp.MakeFeatureLayer(myOutputConnexion + os.sep + "SY_PLN_MON_INFO.LLPG_POINTS","OLD_LLPG_POINTS","GIS_TIMESTAMP <> TO_DATE(' + ExactScriptTime ','YYYY/MM/DD HH24:MI:SS')")

The ExactScriptTime variable value is 21/08/2012 13:00:07 (which gets created in at the start of the script).

I know that the feature layer is empty because i have exported the feature layer into an FC, and it is empty.

Has anyone got any ideas on where I am going wrong.

Thanks

  • I think your problem is that you are comparing the "GIS_TIMESTAMP", which is a date and time combination, with a "TO_DATE", which you are trying to fill with a date and a time. I've seen other cases that had problems with Timestamps, etc. The other thing you might look at is you seem to have an extra "+" sign in front of your ExactScriptTime variable. It doesn't seem to be accomplishing anything, but could be invalidating something. Finally, check your double and single quotes in your TO_DATE function, as they look a little wonky. – Get Spatial Aug 21 '12 at 15:21
  • 1
    Can you post your code that generates the ExactScriptTime variable? – RyanKDalton Aug 21 '12 at 17:18
2

In your first example, 00:00:00 is added to ExactScriptTime which would result in 21/08/2012 13:00:0700:00:00.

Try this:

    gp.MakeFeatureLayer(myOutputConnexion + os.sep + "SY_PLN_MON_INFO.LLPG_POINTS","OLD_LLPG_POINTS","GIS_TIMESTAMP <> TO_DATE('" + ExactScriptTime +"','DD/MM/YYYY HH24:MI:SS')")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.