Custom Date End Of Month Follow

0
Avatar
Legacy Poster

Hi, I am pretty new to BarTender. I need to create a date that automatically sets to the last day of the month. I have created a couple for the first day of the month which was pretty easy for me. I think I will have to use VB Script but it is a little over my head right now. I do not have a ton of computer knowledge and I'm pretty much self taught. I have a general idea how to do it just not sure of the specifics on exactly how and where to enter the commands.

 

Thank you for any help you can give me.

6 comments

0
Avatar
Legacy Poster
Comment actions Permalink

Hi,

 

I can't offer a true-and-tested method, but maybe this will help:

When you look at the properties of an object on your label, there is a "data source" entry, which represents a substring - or, in layman's terms, the actual content that will be printed for that object. Now, you can change the data source type on the right (default is "Embedded Data"). Change it to "Visual Basic Script", then select "Event Control Scripts" for the script type. Click "Edit with Script Assistant...", then on the left, click the OnAutoSelectedEvent entry in the list. Here, you can enter your code.

 

To get the result of your code to display in the object, you need to assign the result to the variable "Value", at the end of your script, like this:

Value = your_result

To go into your actual request: I did a quick Google search which brought up an MSDN page suggesting the use of the DateSerial function. For the function to work, you need to pass it a year, a month and a day. If you enter 0 for the day, the function will use "the previous day" and calculate a new date. So if we tell it to use the year 2015, month 9 and day 0, it will yield the last day of August, the 31st.

 

This is how the code looks like with the above mentioned parameters:

DateSerial(2015, 9, 0)

Now, that's quite static. It'll always yield 31st of August 2015.

So I'll assume you want it to show the last day of whichever month the label is printed in. To do this, we can use additional functions and implement them into DateSerial:

Value = DateSerial(Year(Date()), Month(Date())+1, 0)

Date() yields the current system date. Year() and Month() yield the year and month of Date(), respectively. We add +1 to that month, and enter 0 for the day, so DateSerial() takes the "previous day of the first day of the next month", which is equivalent to the last day of the current month. Then we assign the result of DateSerial() to Value.

0
Avatar
Legacy Poster
Comment actions Permalink

  1. YES!!!  Thanks for breaking it down for me. I really appreciate that!

Thank you! :D

0
Avatar
Lukasz Cichon
Comment actions Permalink

Hi

I am new to the Bartender & have found above tips very helpful.

Above script is "pulling" information from "computer calendar" and i need to get something what will do same job, but based on the date from "Database Sources".

 

Is it possible to achieve it on Bartender version 10.1 SR4?

Thank you in advance :D

0
Avatar
Jasper Wen
Moderator
Comment actions Permalink

Sure, if you would like to reference values from a database field in vbscript, the syntax would something like Field("insert field name here"). This will pull value for that field from your connect database set in BarTender.

0
Avatar
Lukasz Cichon
Comment actions Permalink

Apology.

I think I was not clear enough with my intention.

I need to be able to choose a date from my database (eg. 01.01.2016)

and based on that I need bartender to create a barcode lets say 9 mths from above and default it to end of month (eg. 30.09.2016)

 

Thank you in advance

1
Avatar
Lukasz Cichon
Comment actions Permalink

Hi

How can I change:

Value = DateSerial(Year(Date()), Month(Date())+1, 0) (which is defaulting date into end of month based on system calendar)

into the same result (so it will return end of month date), but based on "Object Value" (which is named Text 9).

 

I am really struggling to get this sorted...

 

Thank you for any help you can give me :D

 

Please sign in to leave a comment.