Skip to main content

Search

Search

Calculating A Date

Comments

6 comments

  • Avatar
    Ian Cummings
    Moderator
    Use an OnProcessData VB script on the data source that connects to your offset value. The script would then be something like the following depending on the type of date format you want.

    [code]
    value = DateAdd("m",value,Date)
    [/code]

    or if you want the date in a YYYY/MM/DD order:

    [code]
    varShelfLife = DateAdd("m",value,Date)
    value = Year(varShelfLife) & "/" & Month(varShelfLife) & "/" & Day(varShelfLife)
    [/code]

    You can of course mix the last example around to best suit your needs.
    0
  • Avatar
    Legacy Poster
    Thank you so much for your help.
    Unfortunately, this goes way over my head!
    I have been able to copy the scripting from another label which seems to be working fine. However, I need to get the month name to display in its abbreviated format - Mar for March, Feb for February etc. I just can't seemt to be get this part working on this script.
    The script I'm currently using is:

    temp = DateAdd("m",BB,Date)
    temp = DateAdd("d", DD,temp)
    daydd = Day(temp)
    if len(daydd) = 1 then daydd = "0" & daydd
    Value = daydd & " " & MonthName(Month(temp)) & " " & Year(temp)


    I'm happy for this to be rewritten for me if it is not the way it should be (which I wouldn't be surprised!), but I will need instructions on how to implement it.


    Thanks
    Gemma
    0
  • Avatar
    Ian Cummings
    Moderator
    For the short version of the month name you need to use the second attribute of the MonthName() function setting it to true.

    Example: MonthName(10,True) with result in the value: Oct
    0
  • Avatar
    Ian Cummings
    Moderator
    It should be noted that BarTender v10, which has just been released, fully supports variable date offsets and date formats as a built-in feature without the need to do VB scripting. You can download a Trial of v10 from the below link:

    http://www.seagullscientific.com/aspx/free-bar-code-label-printing-software-download.aspx

    The what's new in BarTender v10 white paper can be found in the below link:

    http://s3.amazonaws.com/SeagullBarTender/ftp/WhitePapers/WhitePaper_WhatsNewInBT10.pdf
    0
  • Avatar
    Legacy Poster
    I will look into version 10 but as we only bought 9.4 within the last six months it won't be an immediate purchase.

    I'm sorry to be pedantic, but I really don't understand how to use that instruction above regarding the MonthName. I understand about the need to use True, but I just cannot work out how to insert that particular aspect into the VB script we have in place. Can you please show how to insert: MonthName(10,True) into the script below:

    temp = DateAdd("m",BB,Date)
    temp = DateAdd("d", DD,temp)
    daydd = Day(temp)
    if len(daydd) = 1 then daydd = "0" & daydd
    Value = daydd & " " & MonthName(Month(temp)) & " " & Year(temp)
    0
  • Avatar
    Ian Cummings
    Moderator
    You need to count your parentheses. In any case see the below example:

    [code]
    temp = DateAdd("m",BB,Date)
    temp = DateAdd("d", DD,temp)
    daydd = Day(temp)
    if len(daydd) = 1 then daydd = "0" & daydd
    Value = daydd & " " & MonthName(Month(temp),2) & " " & Year(temp)
    [/code]
    0

Please sign in to leave a comment.