跳至主內容

搜尋

搜尋

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

評論

7 條評論

  • Avatar
    Ian Cummings
    版主

    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
    版主

    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
    版主

    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

登入寫評論。