set expiry date automatically based on input creation date
Hi all,
I got create input name which is 'CreateDate' and user able to input/change the date in form display before proceed to do printing. but how can I create the expiry date based on CreateDate + 2 years? CreateDate format is ddMMyyyy and also can be WWYY, and yyyyMMdd.
please advise/help.
thank you
-
Peter Thane
★ BarTender Hero ★
If you are using either BarTender 2016 or 2019 then this process is fialry simple as you can use the Transforms>Offset option and then tick the Apply Offset after Data Entry option. For older versions this is more difficult as you would need to use a VB script routine to achieve this.
Are the three different date formats on the same label template? If so you will you will need to use a VB script routine to link them together as the sharing or just linking them via the Named Data Source option will not work in this instance.
Once you have selected the Data Type as Date for your label field you can then choose how you want the data to be displayed. There are various standard layouts in the list but if you cannot find the one you want then you can select Custom and then type the requirements in the pattern. As you can see the image below shows the WWyy you require.. If you search for Custom Date and Time Format Strings in the Help menu you will be able to see the various options that can be used for the custom option.
I hope this helps.
1 -
Danny chuang
★ BarTender Hero ★
- This is how I work for it...hope to help you. I think there is a "Text Properties" which is link to "input" in template. Maybe use "Search andReplace" in the "Transform" of the Text Properties". I create an action list which is "yyWW" become to "yyyyMMdd".
- Certainly creating action list spend a lot of time. After you create 3 or more actions, export to XML file. Using Excel to open the XML file and it's easy to create more actions. Of course Import the XML file when you finished it. See the picture below.
- As you ask how can I create the expiry date based on CreateDate + 2 years? CreateDate format is ddMMyyyy and also can be WWYY, and yyyyMMdd. I think it's better to do in Excel file.
0 -
Peter Thane
★ BarTender Hero ★
From your other post Danny I see you are using v10.0. I certainly cant remember handling date formats changes the way use are proposing as I seem to recall there was a date option already that could deal with this. However as BarTender has no been available to purchase for around 7 years and came to the end of support in 2017 i no longer have access to this and so cannot confirm.
I do know the Offset in the Transforms option was not present in 10.0 and so what I suggested above would not be possible for you to implement. For that version I would have used a VB Event Controlled Post Prompt script routine to include a DateAdd 2 years option, so something like
Value = DateAdd("yyyy",2,Value)
1 -
Danny chuang
★ BarTender Hero ★
Thanks a lot. This is a topic that I am interested in. I am confronted different customers request different date format.
0 -
ameer ameer
★ BarTender Hero ★
Hi Pete Thane and Danny Chuang,
thanks for the advise. I will try out your suggestions. My workplace got version 10, 2016, and soon will purchase 2019.
0 -
Peter Thane
★ BarTender Hero ★
Hopefully this will explain the process.
1. Give the field that will contain the base/chosen date a name via the use of the Change Data Source Name button. To match the original post I have called it CreateDate.
2. For the offset date field set this to have a Date Data Type and choose an appropriate format as per the 2nd image in my post above.
3. Amend the Data Source to Visual Basic Script and choose the Event Controlled Script option and then then press the Edit.... button
4. In the column on the left choose the OnPostPrompt option and in the central box add the code shown on the screen below. Please note for the 1st line type the Value = and then double click on the name set in 1. from the right column to add the link to this field
5. Click close and you are done.
0 -
ameer ameer
★ BarTender Hero ★
Hi Pete Thane,
I create "CreateDate" as shown above picture. Date is ddMMYYYY.
Then I create "ExpiryDate" with date format ddMMYYYY, but when I set the vb script and want to close it, got error as below;
Please advise.
Thank you.
0 -
Peter Thane
★ BarTender Hero ★
Not had a chance to look at this yet but,sometimes as the VB is trying to process a string of characters rather than proper data when you set up the config screen sometimes you get the Type Mismatch until actual data is available at the proper On....Event time.
If you add a ' at the front of the first line and then add a temporary new line
Value = "26082020"
does the mismatch error at the bottom disappear?
In which case the original code is probably okay anyway and if you try printing with the original commands it may work correctly.
I will try and look at this again tomorrow if I have time anyway.
Pete
0 -
ameer ameer
★ BarTender Hero ★
Hi Pete Thane,
Do you mean like above? still got the error.
0 -
Peter Thane
★ BarTender Hero ★
The problem is BarTender/VB is not recognising ddMMyyyy as a date format and so cannot perform the DateAdd command. If you amend CreateDate so it is set to dd/MM/yyyy format and then drag it off the label so it doesn't print but can still be referenced you can then add a 2nd VB item but remove the DateAdd line. For both the VB fields set the Type to Date and use Custom ddMMYYYY.
0 -
ameer ameer
★ BarTender Hero ★
Hi Peter Thane,
Revisit this topic. I using the script that you share last time. But this time the date format is YYYY/MM/dd. For Expiry date, I got create at data type tab the format YYYY/MM/dd, but when doing the script, the output become dd/MM/YYYY. Is there anyway to make it follow YYYY/MM/dd ?
Please advise. Thank you.
0 -
Peter Thane
★ BarTender Hero ★
Hi Ameer,
I think is you amend the formatting as shown below then that will work.
Pete
0 -
ameer ameer
★ BarTender Hero ★
Hi Peter Thane,
I already done that but still same. Any possibility to set in in vbscript? Maybe vbscript overwrite the feature of this date format?
Please advise. Thank you
0 -
ameer ameer
★ BarTender Hero ★
Hi Peter Thane,
Manage to find the solution to convert in vbscript
https://support.seagullscientific.com/hc/en-us/community/posts/216578107/comments/221989627
Thank you.
0
Vous devez vous connecter pour laisser un commentaire.
Commentaires
14 commentaires