1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

All Years In Between

Discussion in 'C#' started by mrbrantley, Mar 28, 2008.

  1. #1
    Hey all! I am currently using javascript / asp in my online application. I have data which dynamically presents years such as 1999-2003. I need to see if there is a script that can "explode" these years to present 1999, 2000, 2001, 2002, 2003. I cannot for the life of me figure it out.

    Thanks in advance!
     
    mrbrantley, Mar 28, 2008 IP
  2. tacosalad

    tacosalad Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    In ASP you can do something like:

    ' set variables
    dim yearRange
    dim startYear
    dim endYear
    dim yearsList

    ' get the year range as a string
    yearRange = "1999-2003"

    ' split the string into two values
    myArray = split(yearRange,"-")

    ' get the starting and ending years from the two array indexes
    startYear = myArray(0)
    endYear = myArray(1)

    ' use a for next loop to iterate through the
    ' begin and ending years with years between
    for x = startYear to endYear
    if len(yearsList) = 0 then
    yearsList = x
    else
    yearsList = yearsList & ", " & x
    end if
    next

    ' output to screen
    response.write(yearsList)
     
    tacosalad, Mar 28, 2008 IP
  3. mrbrantley

    mrbrantley Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    Thank you so much! Works like a champ!
     
    mrbrantley, Mar 28, 2008 IP
  4. tacosalad

    tacosalad Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Glad to help. That's one way. I'm sure there are others. If anyone has any other methods it would be cool to see them.
     
    tacosalad, Mar 28, 2008 IP
  5. kadesmith

    kadesmith Peon

    Messages:
    479
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    That's really the only way I'd suggest doing it
     
    kadesmith, Mar 29, 2008 IP