Select to view content in your preferred language

Python script tool set input Date parameter to Date format by default

877
1
07-06-2023 11:07 AM
JohnNergeBrooklynPark
Frequent Contributor

This post gets really close to what I'm trying to do, but I can't quite figure out how to implement. Had anyone figured out how to set the default type on a Date input parameter to Date instead of the default Date and Time radio button?

I did test the option of setting a default value on the parameter to be a date (e.g. 1/1/2023), and that works, but I'd rather not do if we can just get at that radion button setting directly instead.

1 Reply
RogerDunnGIS
Frequent Contributor

I did this (inspired by the link you provided) and it works okay:

def updateParameters(self, parameters):
        if parameters[1].altered:
            parameters[1].value = datetime.datetime.combine(parameters[1].value, datetime.time())

 

What ends up happening is that, at first, the "Date and Time" option is selected.  Maybe that can't be helped.  But once the user closes the drop-down calendar, the time is stripped off in the edit control, and the next time they click the clock button, the "Date" option is selected.

0 Kudos