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

3
  • Anything on here help: geonet.esri.com/thread/53231 Commented Feb 11, 2015 at 17:46
  • Is your field a date format field, or a text field? Commented Feb 11, 2015 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
    Commented Feb 11, 2015 at 18:08

2 Answers 2

3

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

[Diameter] & " " & [Material] & " Installed: " & Year([InstallDate])
3
  • OMG! WOW! That's it?! I guess I need to school myself in VBScript formatting. Thank you so much recurvata. That worked perfectly!
    – AReaGIS
    Commented Feb 11, 2015 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
    Commented Feb 11, 2015 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
    Commented Feb 11, 2015 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.

2
  • 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
    Commented Feb 11, 2015 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
    Commented Feb 11, 2015 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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