1

I was hoping someone could help me with this. I know this is probably easy but I am still new to ArcMap.

I need to label pipe mains with the year installed but my attributes have the entire date. How can I format the label to only display the year (yyyy)? I am using ArcMap 10.2.2 and VBScript. I have included screenshots to show where I am at currently.

Labeling Screenshot 1

Labeling Screenshot 2

  • Anything on here help: geonet.esri.com/thread/53231 – DPSSpatial Feb 11 '15 at 17:46
  • Is your field a date format field, or a text field? – Get Spatial Feb 11 '15 at 17:57
  • It is a date field. I did the simple VBScipt command recommended by recurvata and it worked flawlessly. Thanks for the reply Get Spacial. – AReaGIS Feb 11 '15 at 18:08
3

You should be able to use the Year function directly in your label expression:

[Diameter] & " " & [Material] & " Installed: " & Year([InstallDate])
  • OMG! WOW! That's it?! I guess I need to school myself in VBScript formatting. Thank you so much recurvata. That worked perfectly! – AReaGIS Feb 11 '15 at 18:03
  • 3
    You may want to look at using python instead of vbscript (can change that in the parser drop down), since it's more versatile, at least for more complex scripts, but what works works, eh? – recurvata Feb 11 '15 at 18:06
  • I must admit that I have not put aside enough time to dive deep into understanding the scripting process, especially python. Thanks again recurvata. – AReaGIS Feb 11 '15 at 18:15
1

Here is one way of doing it:

  1. Add an integer field 'InstallYear' to the attribute table.
  2. Use the Field Calculator on the new 'InstallYear' column, then enter this:

InstallYear = year([InstallDate])

From here you can simply change your label expression to:

[Diameter] & """ & [Material] & " " & "Installed: " & [InstallYear]

Alternatively (and probably easier):

  1. Select the "Advanced" checkbox in the label expression.
  2. Set the expression to:

FindLabel = [Diameter] & """ & [Material] & " " & "Installed: " & Right([InstallYear], 4)

This however requires that the data is in the same format for each row.

  • Thank you for the reply John. Unfortunately, this pipe mains feature class is controlled by a corporate SDE so I cannot add any additional fields. I could export it as a shape file and edit the shape file. The only problem with that though is I will be editing the mains. I do not want to have to export a new shape file every time. – AReaGIS Feb 11 '15 at 17:51
  • @ReaDaddy I see. Have a look at my edited answer and see if that works for you. It might take a bit of tweaking. – sto.j Feb 11 '15 at 18:03

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.