Date Issues Follow

0
Avatar
Legacy Poster

Hi,

I need to create a manufacture date and also an expiry date.

I have created a manual input for the manufacture date which is OK, but for the expiry date I would like it to use the manufacture date plus add 3 years, the only issue is the format for the expiry date needs to be YYYY-MM so 2014-08. I can't see this option in the date format dropdown box, is there a way to format this date?

I'm pretty new to Bartender, so still learning the basics.

Regards,

Mick.

6 comments

0
Avatar
Susan Chen
Moderator
Comment actions Permalink

For the Date format which are not on the dropdown lists, There are two ways you can achieve this requirement


1) Use Date datesource + Substring function + offset to achieve this 2014-08

a) Drop a "T" text object on the design area. Choose "Date" as source on Data Source tab
B) From the Date dropdown list, choose 2011(Year:4 Digits) format
c) Tick the "offset by" option and put 3(You want to add 3 year for expiration date)and choose "Year(s)" as Unit-> You have 2014
d) Click on "Advanced" Tab, on the left side of "Sub-String List" click on "New" icon at the bottom or double click to add Substring "-" screen data -> You have 2014-
e) Add another substring, Choose "Date" as source on Data Source tab.From the Date dropdown list, choose 08(Month:2 Digits) format-> You have 2014-08



2) VBScript: If you are pretty new to Bartender, you can try it when you are more ready. There are few ways to write it depend on your preference. You can use VBScript "Dateadd" function to add 3 on the year part and use string functions(for example Right, Mid, left) and string contenation to achieve the date format you want it to look like


Thanks!
0
Avatar
Legacy Poster
Comment actions Permalink

Thanks Susan,
That works great, but is there anyway to link the output of this to another date field ( manufactured Date ) this is in the format 12 Aug 2011, this is a manually entered date.. so if manufactured date is 12 Aug 2011 then expiry date will be 2011 - 08.

Hope this makes sense?

Thanks again for your help with this.

Regards,

Mick.
0
Avatar
Domingo Rodriguez
Moderator
Comment actions Permalink

Hello Mick,

I've attached a label format sample for you to examine.

This sample uses some VBScript code in order to link both date objects together and in the desired formatting.

The VBScript written for the Expiry Date is as follows:

value = DateAdd ("yyyy", 3, Format.NamedSubStrings("manudate").Value)
value = Right (value, 4) & " - " & Mid (value, 4, 2)

Please note that "manudate" is the shared sub-string name I've given to the Manufacturing Date. In order to set this name, you could open the properties for the manufacturing date object, select the "Data Source" tab, press the "Advanced>" button, now select the "Share / Name" tab and write the name you're wishing to give to the shared sub-string.

When you open the properties for the expiry date you will see that I've chosen "Visual Basic Script" as the Source. If you press the "Edit..." button you will also see the VBScript code.

Please modify this sample for your own needs. If you've any questions or if this sample doesn't work as required, please let us know.
0
Avatar
Legacy Poster
Comment actions Permalink

Hi Domingo,

Thanks for your reply, It looks like you have used a newer version than I have ( 8.01 ) so it wont let me open your sample, but I will give it a go and see if I can get it working just by your example.

Regards,

Mick.
0
Avatar
Legacy Poster
Comment actions Permalink

Hi,

OK I got it working ( sort of )

I used the code you gave:
value = DateAdd ("yyyy", 3, Format.NamedSubStrings("manudate").Value)
value = Right (value, 4) & " - " & Mid (value, 4, 2)

but this gives 2018 - 08 which is 4 years too many, not sure if this makes any difference but the format of manudate is dd/mm/yy??

if I chnage DateAdd ("yyyy", -1 then it give the correct year 2014

I have a prompt for order_id which brings back the specific order then I have a prompt which I enter the manudate ( which is also dd/mm/yy ) when I do this it gives an error " Line 1 : Type mismatch; '[string:""]'>

If I click continue and put the year in as 2011 then it runs OK.

Any idea why this is happening and what I can do to get around it?

Regards,

Mick.

After looking at it a little more, it looks like its taking the dd as the year as now its the 16th its moved the expiry date to be 2019 - 08, any ideas how to solve this?
0
Avatar
Domingo Rodriguez
Moderator
Comment actions Permalink

This could be due to specific regional settings on your computer. I've attached now the sample label format in version 8.01. Please test the sample and let me know if you still get the same problem, in which case I will take another look at what might be going wrong.

Please sign in to leave a comment.