Here is a criteria how I open my recordset:

criteria = "SELECT [Date], [Time], " + MyField + " FROM " + MyDB + " WHERE Time >='" + StartTime + "' AND Time <='" + EndTime + "' AND Date =#" + MyDate + "#"

I would like to add there one variable called Step.

I mean that if there is field in my database for every 1 minutes and I wanna open recordset only for every 15 minutes (Step is 15 minutes).

Is this even possible?? If it is, would you give me an example!

Thanks in advance!

criteria = "SELECT [Date], [Time], " + MyField + " FROM " + MyDB + " WHERE Time >='" + StartTime + "' AND Time <='" + EndTime + "' AND Date =#" + MyDate + "#"

I would like to add there one variable called Step.

I mean that if there is field in my database for every 1 minutes and I wanna open recordset only for every 15 minutes (Step is 15 minutes).

Is this even possible?? If it is, would you give me an example!

Thanks in advance!

1. syntax for "n" should be 'n'(my fault i generated this in access)

2. If datediff or datepart = 0 then then the mod will always be crop up, since the bigger the number the more chance something = to 0, so datepart will return all times with XX:00 and datediff will return all times were for eg (12:00 = 12:00)

3. If datediff is big enough, then mulitple false values will will be a factor, and hence mod = 0

the best i can do is

Sqlstr = "SELECT * From Table1 Where (Table1.Date = Date) And (Table1.Time >= #12:00:00 PM#) And (Table1.Time <= #5:00:00 PM#)AND (((Datediff('n',#" & mydate & " " & starttime & "#,Table1.time) ) mod " & step & ") = 0)"

where step = number of minutes in step eg. 1440 for one day

You may need to combine the table1 time and date to avoid erorrs as stated in 3. and 2.

so if you ask for the minutes datepart of 12:00 = 0 and, 0 mod 120 = 0, so the database thinks this record is ok and thus passes it back to your VB recordset

This also happens with datediff function if you give two times, if they are the same eg 12:00 and 12:00 then even though they have different dates and thus are different by n* 1440 minutes, the function knows nothing about their dates and just thinks they are on the same day, so you get 0 and the same problem as above.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.