candian date format
hi look at the other post regarding this and could not figure this out the version I am running is bartender 2016 R3
could you provide a step by step method for this please
-
There is a way to do this without resorting to VB scripts:
1) Create a non-printing date/time object (can be off-label, on a 'Never Print' Layer, or the object itself is set to Never Print). Set the format to yyyy-MM-dd H:mm:ss.
2) Create a new Text Object, and make it's data source an Object Value of the original Date/Time object:Next make the Data Type "Text"
Then, using the Transforms tab, first Truncate the value to desired length (I used 'Keep characters on left' set to 10)
and then create 12 Search and Replace actions, one for each month, using the hyphens "-" on either side of the Month number to uniquely identify the target block and replaced them with spaces and the desired letters.
(My apologies if I got any abbreviations incorrect. I do not know off-hand the official abbreviations used by our northern friends.)Here is an image of the sample label I put together:
Why this works:
In BarTender, different data sources are allowed different kinds of manipulation. When working a system based Data Source, such as Clock, one of the restrictions is that the field definition must remain as either Date or Time. This means that the Transforms available for that kind of data object are mainly limited to things that do not fundamentally alter the underlying data.
This is one of the reasons that many years ago BarTender created Object Value links. An Object Value link captures copies of the displayed value of another object. This is a one-way copy. Any changes made to the copy are not reflected back to the original data source.
This allows the copied value to be manipulated in ways that the original source cannot. In this case, we can change the defined object type from Date to Text. Doing so immediately makes available the Search and Replace Transform that we want for this situation.
The Object Value is also useful when you have a single source of data that you need to represent several different ways. You can have each variation object make its own Object Value connection to the original data source. Try it out on other projects!
Additional Information:
I did this BarTender 2021 Professional, although it should work for previous versions, perhaps as far back as BarTender 2016?There are a couple of big advantages to doing it this way, as opposed to VB scripts:
A) It is faster to create and also update or otherwise modify than a VB script solution.
B) Less likely to pose an issue when updating to newer versions of BarTender down the road.I would be happy to share the sample template with anyone who would like it. Just email me care of sales@seagullscientific.com.
Lee Stevens
Sr. Sales Engineer -
Peter Thane
★ BarTender Hero ★
I am guessing that the header included a typo and you mean Canadian Date Format.
In your text field, set the Source to Clock and then on Data Type tab adjust the Locale to English (Canada) and then various different layouts will be selectable from the list.
If none of these suit your requirements , choose the Custom option and amend the "Pattern" box to , such as YYYY-MMM-dd to print 2020-Feb-19 etc.
0 -
Peter Thane
★ BarTender Hero ★
Sorry meant to have added this image to the above
-1 -
james nugent
★ BarTender Hero ★
Sorry I am looking the Canadian bi lingual date format. January. Is JA. February is FE. March is MR. Etc
0 -
Peter Thane
★ BarTender Hero ★
Okay, not come across that before and so not sure what the other months should be and so you may need to adjust a couple of bits I am guessing
- Add a date field onto you label (or off the side if you dont need to print it) and make it use one the normal date formats
- On the Data Source tab of this field click on the Change Data Source Name button and give this field a name. I used PackDate for my sample
- For your Canadian date field add a text field onto the label and give it a Visual Basic Script source
- I would suggest you make the type Event Controlled Script rather and then click the Edit with Script Editor button (see screenshot below)
- In the central edit box (with OnAutoselectedEvent still selected in the column on the left) change the code to Value = Now()
- Now scroll down in the left hand column until you come to OnIdenticalCopies, select this and then in the central box add in the code below. For the first line type in Value = and then in the right hand column double click on the name you gave in 2 to add the "Format.NamedSubStrings("PackDate").Value" part.
- For the CamMonth Array line I have guessed at the other month abbreviations and so you will need to change these and also for the final line that determines how the data is displayed, I am guessing you will need to tweak this to match the output you require, such as - instead of / or perhaps in a different order etc, but hopefully this will point in you in the right direction.
Here is the code I used and there are some screenshots below too which I hope help.
Pete
Value = Format.NamedSubStrings("PackDate").Value
Dim CanMonth
CanMonth = Array("0","JA","FE","MR","AP","MY","JN","JL","AU","SE","OC","NO","DC")Value1 = Day(Value)
Value2 = Month(Value)
Value2 = CanMonth(Value2)
Value3 = Year(Value)
Value = Value1 & "/" & Value2 & "/" & Value3
1 -
james nugent
★ BarTender Hero ★
Hi
I tried this but there was no " visual basic script source " or "edit with script editer "button I. Running the basic edition of bar tender. The version I am using is 2016 r3 basic. Would I need to update0 -
Peter Thane
★ BarTender Hero ★
Yes unfortunately, you would need to upgrade to the Professional edition
0 -
Tahir Lifanov
★ BarTender Hero ★
Hi Pete.
Happy new year!!!
how can we make the year to be 2 digits instead of 4?
Thank you
0 -
Peter Thane
★ BarTender Hero ★
The simplest way would be to add a new line of code after the Value3 = Year(Value) namely
Value3 = Right(Value3,2)
0 -
Tahir Lifanov
★ BarTender Hero ★
Thanks Pete
its perfect.
0 -
George Nunes
★ BarTender Hero ★
Thank you Lee.
Great instructions regarding Canadian Date Format as opposed to VB scripts..
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
11 Kommentare