VBScript help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • antonopn
    New Member
    • Mar 2008
    • 42

    VBScript help

    Hello there...
    I have a SQL-VB problem.
    I use a program for a company. It inserts values to a table.

    lets says table1
    ID, date, amount

    I use a vbscript that changes the date. But when in table1 many rows with the same id are inserted, only the last row is affected and the date is changed to the desirable value. I want a kind of loop that will be executed when some rows have the same id.

    Any ideas?

    I give you the part of the VBScript
    Code:
    YP=DATEPART("YYYY",DATE.VALUE)  
    MP=DATEPART("M",DATE.VALUE)  
    N= DATEPART("D",DATE.VALUE)  IF N>0 AND N<16 THEN 
    DP=12  
    END IF  
    IF N>15 THEN  DP=27  
    END IF
    END IF  
    temp="'"&DP&"/"&MP&"/"&YP&"'"  
    DATE.VALUE= DB.QUERYRESULTS("select convert(datetime,"&temp&",103) as result",null,"result")
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Hey there!

    Not sure what you are asking, but do stay tuned for a VB Script expert. Also, I would post the whole code just in case someone needs to see it, saves you time and wait;-)

    Good luck with project!

    Dököll

    Comment

    • antonopn
      New Member
      • Mar 2008
      • 42

      #3
      Thanks for the answer.
      I would be glad if someone could tell me how will I make a loop and execute there the code I quoted.

      example:
      Code:
      do where id=123456  ...mycode...  end loop

      Comment

      • antonopn
        New Member
        • Mar 2008
        • 42

        #4
        If anyone could help please?

        To be more specific.
        I have a table with these values

        ID | VALUE | DATE
        10 | 140.00 | 2008-01-01
        10 | 255.00 | 2008-02-10
        10 | 102.00 | 2008-03-31
        11 | 651.00 | 2008-05-26
        12 | 412.00 | 2008-06-15

        I execute a VBScript that makes the day=27 no matter the month or the year. But when the ID is the same it does it only for the last row. My results are:

        ID | VALUE | DATE
        10 | 140.00 | 2008-01-01
        10 | 255.00 | 2008-02-10
        10 | 102.00 | 2008-03-27
        11 | 651.00 | 2008-05-27
        12 | 412.00 | 2008-06-27

        But my DESIRED results are:

        ID | VALUE | DATE
        10 | 140.00 | 2008-01-27
        10 | 255.00 | 2008-02-27
        10 | 102.00 | 2008-03-27
        11 | 651.00 | 2008-05-27
        12 | 412.00 | 2008-06-27

        Can anyone PLEASE help?

        Comment

        Working...