By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,983 Members | 2,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,983 IT Pros & Developers. It's quick & easy.

VBScript help

antonopn
P: 42
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
Expand|Select|Wrap|Line Numbers
  1. YP=DATEPART("YYYY",DATE.VALUE)  
  2. MP=DATEPART("M",DATE.VALUE)  
  3. N= DATEPART("D",DATE.VALUE)  IF N>0 AND N<16 THEN 
  4. DP=12  
  5. END IF  
  6. IF N>15 THEN  DP=27  
  7. END IF
  8. END IF  
  9. temp="'"&DP&"/"&MP&"/"&YP&"'"  
  10. DATE.VALUE= DB.QUERYRESULTS("select convert(datetime,"&temp&",103) as result",null,"result")
Jun 9 '08 #1
Share this Question
Share on Google+
3 Replies


Dököll
Expert 100+
P: 2,364
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
Jun 10 '08 #2

antonopn
P: 42
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:
Expand|Select|Wrap|Line Numbers
  1. do where id=123456  ...mycode...  end loop
Jun 10 '08 #3

antonopn
P: 42
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?
Jun 18 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.