Saltar al contenido principal

Búsqueda

Búsqueda

Change Month To A Letter 1=A, 2=B, 3=C Etc.

Comentarios

7 comentarios

  • Avatar
    Ian Cummings
    Moderador

    Under the "Transforms" tab of the month data source you could create 12 search and replace actions for each month of the year.

    0
  • Avatar
    Legacy Poster

    Thanks!  How do you enter the search and replace for months 10, 11 & 12?  I was getting "AA" for Nov. and AB for Dec.  There isn't a search and replace option when you select date from the Data Type tab. So I tried pulling in from the excel sheet I have linked and thought I had it but can't get the double digit month part figured out. I'm so close!

     

    Thank you

    0
  • Avatar
    Ian Cummings
    Moderador

    Select the option to use a Regular Expression and do the search on ^12$ where the number represents the number of the month.  If your BarTender version doesn't support this then use VB script with a 12 case Select statement.

    0
  • Avatar
    Legacy Poster

    Ahh ok, I was missing the "^"

     

    Working great now!

     

    Thanks Ninja! :D

    0
  • Avatar
    Ian Einman

    If someone does want a VB Script to convert the month into a letter, here it is:

     

    Mid("ABCDEFGHIJKL", Month(Date), 1)

     

    You can use this as a single-line expression, and then just add a second data source of type Clock to get the YY part.

     

    This works because the "Mid" function will take a substring of the first string, starting at the specified index (in this case the month as a number from 1-12) and of the specified length (1 character).  This same concept can be used to turn the weekday number into a letter as well:

     

    Mid("UMTWRFS", Weekday(Date), 1)

    0
  • Avatar
    Petya Dimitrova

    Hi, 

    Would this still be valid for the most current versions of Bartender. I have tried to use and the following error appears: 

     

    OnProcessData (Line 1): mid("ABCDEFGHIJKL",Month(date),1): Cannot use parentheses when calling a Sub

     

    Looking forward to get linked field to transform to alphabetised month display. Thanks

     

    0
  • Avatar
    Ian Cummings
    Moderador

    Not sure what you're doing wrong, but the code example, given by my colleague Ian Einman in an earlier post, works just fine in a single line VB script within BarTender 2022 R2.

    Perhaps yours is a multi-line or event based script, and you forgot to add the assignment to value in your expression giving: value = Mid("ABCDEFGHIJKL", Month(Date), 1)

    0

Iniciar sesión para dejar un comentario.