VB Script, Number of weeks between two dates
I am looking to output the number of weeks between todays date and a field date.
My current script returns 0
Value=DateDiff("ww",Now,Format.Objects("DatePulled").Value)
My DatePulled value is from a Database field. I get the same output if I use the Database Field instead:
Value=DateDiff("ww",Now,Field("Modulus.Modulus Data.Date Pulled"))
What do I need to do to obtain a week count between two dates?
-
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 -
This worked great! Thank you very much!
0
Please sign in to leave a comment.
Comments
2 comments