Calculating A Date S’abonner

0
Avatar
Legacy Poster

I'm fairly new to using BT, and having a few issues with trying to figure out how to generate a date in the future. Our labels require an expiry date of our product, which can be anything from six to 12 months from date of manufacture. We record the number of months this should be in the database linked to the label, but I can't figure out how to get BT to generate the date. For example, today is 23 Feb, and a product may have an expiry date of 12 months from today, meaning it should print 23 February 2013 on the label. Previous users of BT here have done it through VB scripting, but with MUCH older versions of BT - think 7.1 compared to 9.4 Automation that I'm currently running!

Any assistance with this greatly appreciated.

6 commentaires

0
Avatar
Ian Cummings
Modérateur
Actions pour les commentaires Permalien

Use an OnProcessData VB script on the data source that connects to your offset value. The script would then be something like the following depending on the type of date format you want.

[code]
value = DateAdd("m",value,Date)
[/code]

or if you want the date in a YYYY/MM/DD order:

[code]
varShelfLife = DateAdd("m",value,Date)
value = Year(varShelfLife) & "/" & Month(varShelfLife) & "/" & Day(varShelfLife)
[/code]

You can of course mix the last example around to best suit your needs.
0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Thank you so much for your help.
Unfortunately, this goes way over my head!
I have been able to copy the scripting from another label which seems to be working fine. However, I need to get the month name to display in its abbreviated format - Mar for March, Feb for February etc. I just can't seemt to be get this part working on this script.
The script I'm currently using is:

temp = DateAdd("m",BB,Date)
temp = DateAdd("d", DD,temp)
daydd = Day(temp)
if len(daydd) = 1 then daydd = "0" & daydd
Value = daydd & " " & MonthName(Month(temp)) & " " & Year(temp)


I'm happy for this to be rewritten for me if it is not the way it should be (which I wouldn't be surprised!), but I will need instructions on how to implement it.


Thanks
Gemma
0
Avatar
Ian Cummings
Modérateur
Actions pour les commentaires Permalien

For the short version of the month name you need to use the second attribute of the MonthName() function setting it to true.

Example: MonthName(10,True) with result in the value: Oct
0
Avatar
Ian Cummings
Modérateur
Actions pour les commentaires Permalien

It should be noted that BarTender v10, which has just been released, fully supports variable date offsets and date formats as a built-in feature without the need to do VB scripting. You can download a Trial of v10 from the below link:

http://www.seagullscientific.com/aspx/free-bar-code-label-printing-software-download.aspx

The what's new in BarTender v10 white paper can be found in the below link:

http://s3.amazonaws.com/SeagullBarTender/ftp/WhitePapers/WhitePaper_WhatsNewInBT10.pdf
0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

I will look into version 10 but as we only bought 9.4 within the last six months it won't be an immediate purchase.

I'm sorry to be pedantic, but I really don't understand how to use that instruction above regarding the MonthName. I understand about the need to use True, but I just cannot work out how to insert that particular aspect into the VB script we have in place. Can you please show how to insert: MonthName(10,True) into the script below:

temp = DateAdd("m",BB,Date)
temp = DateAdd("d", DD,temp)
daydd = Day(temp)
if len(daydd) = 1 then daydd = "0" & daydd
Value = daydd & " " & MonthName(Month(temp)) & " " & Year(temp)
0
Avatar
Ian Cummings
Modérateur
Actions pour les commentaires Permalien

You need to count your parentheses. In any case see the below example:

[code]
temp = DateAdd("m",BB,Date)
temp = DateAdd("d", DD,temp)
daydd = Day(temp)
if len(daydd) = 1 then daydd = "0" & daydd
Value = daydd & " " & MonthName(Month(temp),2) & " " & Year(temp)
[/code]

Vous devez vous connecter pour laisser un commentaire.