Skip to main content

Search

Search

VB Script, Number of weeks between two dates

Comments

2 comments

  • Avatar
    Peter Thane

    I would let BarTender do some of the work for you and set the VB to run as an Event Controlled Script > OnNewRecord.

    To do this add a field onto your label area (but off the printed area so it will not appear at print time) and make this a Clock field with a type set to Custom and a Pattern of WW. This will return the value of the week of the year for today's date. Via the use of the button to the right of the Name box on the Data Source tab give this field a suitable name. I used Weektoday as my name. 

    Note I left my fields in the printed area so I could see them when testing. 

    Next add a similar field linked to your database date and again make adjust the Data Type to Date and set a Custom WW pattern for this, to give you the week of the year for your date. Again give this field a suitable and in this instance I used DBWeek

    Finally add a VB Event Controlled Script field set to OnNewRecord and add in the VB that will delete the one date from the other to give the use value you require so something like this (note on Autoselected Events I edited the Value = "Sample Text" to Value = "WeekDiff" but you could use whatever value you like)

    Value = Format.NamedSubStrings("WeekToday").Value

    Value1 = Format.NamedSubStrings("DBWeek").Value

    Value = Value - Value1

    0
  • Avatar
    Hannah Woodhouse

    This worked great! Thank you very much!

    0

Please sign in to leave a comment.