Date Offset With Date Picker At Time Of Print. Follow

0
Avatar
Legacy Poster

Good afternoon.

 

I am having some trouble trying to get something working and need some help ASAP.

 

I have a manufacture date and an expiry date and I can add a date offset of 42 days to the expiry date data source which will add 42 days from the date of printing, but I added a date picker on the manufacture date which allows the operator to change the manufacture date to a future date. I want to know how to link the expiry date of 42 days to the date picker so that when you change the date on the date picker it automatically adds 42 days to the expiry date.

 

I've tried multiple ways of trying to achieve this but it does not work.

 

Some help please?

 

Thanks!

2 comments

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

Set the manufacture date to be a named data source.  The expiry date should use a VB script expression in the data source.  In the VBS expression use the DateAdd() function to add 42 days to the value of the manufacture date.  Its possible that you might need to use an event based VB script for this.

0
Avatar
Legacy Poster
Comment actions Permalink

Managed to get it working. Created a VB event script.

 

 

This code should be applied to the "Expiry Date" and make the manufacture date a named source named "ManufactureDate". The code should be placed in the "Transforms" section of the Data source and is "OnProcessData".

 

Made this code for "Days e.g 42 days":

 

'Example: Value = Value + "123", will append 123 to the data source value.
NewValue = DateValue(Format.NamedSubStrings("ManufactureDate").Value) + "42"

Value = FormatDateTime(NewValue,1)

And this code for "Months e.g. 3 Months"

'Example: Value = Value + "123", will append 123 to the data source value.
NewValue = DateValue(Format.NamedSubStrings("ManufactureDate").Value)

NewDateValue = DateAdd("m",3,NewValue)

Value = FormatDateTime(NewDateValue,1)

The values in bold below are the values which are variable.

 

For Days

NewValue = DateValue(Format.NamedSubStrings("ManufactureDate").Value) + "42"

 

For Months

NewDateValue = DateAdd("m",3,NewValue)

 

Hope this helps other people.

 

Thanks.

Please sign in to leave a comment.