As I am working on several shapefiles that needed to be populate Date in the field column. How do you do assign VBscript in the field calculator to assign for one year for 2010 or 2016 or 2014 ?
Seems every time I tried to follow what ESRI field calculator I get failed ?
like this : Date ( "2016" ) returns failed !
If you have a better suggest or work around, I can do either VB Script or Python.
Thanks
Solved! Go to Solution.
I assume you're trying to calculate this into a date datatype field? I believe you need to supply a day, month, and year to fit the format.
Fundamentals of date fields—Help | ArcGIS for Desktop
A coverage or shapefile stores dates in a date field with this format: yyyy-mm-dd. A geodatabase formats the date as datetime yyyy-mm-dd hh:mm:ss AM or PM.
I assume you're trying to calculate this into a date datatype field? I believe you need to supply a day, month, and year to fit the format.
Fundamentals of date fields—Help | ArcGIS for Desktop
A coverage or shapefile stores dates in a date field with this format: yyyy-mm-dd. A geodatabase formats the date as datetime yyyy-mm-dd hh:mm:ss AM or PM.
Aww.. I see. Thanks !
I also found this https://community.esri.com/thread/16945
and look at what Marcus Perrine wrote. That one worked too..
If your required context is for a year only why not use a integer field instead of a date field? However, if you want to assign a Year only within a date field, then you would have to chose a default value for your Month and day as Darren Wiens link indicates.
If changing your date field to an integer is not an option you can use the the following script and substitute your own default month/day....
CDATE("1/1/2016")
Note in vbscript if memory serves right Date() returns the system date......
Thank you. The reason is that I am asking is because I have the geodatabase that was already done by somebody else and use the template that I cannot change.
Thanks for the suggest !