I am looking for some advice on passing a range of dates to a SQL string that I have.
I want to run my macro and obtain the date part of my SQL string from a cell on another worksheet, currently I have the following line in to achieve this;
SQL_RTSids = SQL_RTSids & "'" & Worksheets("DateRange").Range("A2") & " 06:00:00' "
QUESTION 1 : How can I pass a date to my SQL string (I am currently passing a text string ie ’14-NOV-10 and then adding the time of 0600hrs onto the date within the SQL string.
I also have a list of dates that I want to pass through my SQL.
Given my limited knowledge of creating a SQL string I presume I would need to;
- Create my string using the first date (worksheet ‘DateRange”, cell “A2”) from the other worksheet and paste it from a record set into my active worksheet
- Run the SQL again but this time use the next date (worksheet ‘DateRange”, cell “A3”) on the other worksheet and then paste in underneath the previous set of data
- Repeat the above until the date in the cell is less than sysdate
QUESTION 2 : How can I loop though the data on my other worksheet and include them in my SQL string, stopping when the date is less than sysdate?
Bookmarks