VYX Level: Professor

 Registered: 16-12-2005 Posts: 70
|
Re: SQL statement from today to next day
Hi,
why don't you try to combine the variable date and time into one. it just like vDATETime in order to use query easily.
if that case it just like this
''''''''''''''''''''''''''''''''''''''''''''''''''''
Example:
dbfields station | vDatetime| data
SELECT station,vdatetime,data
FROM tbldatas
WHERE (vdatetime BETWEEN '1/2/2007 08:00:00 am' AND '1/3/2007 08:00:00 am') group by datetime,station
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
InitialDAteTime=date &" " &"8:00:00 am"
DateTomorrow=dateadd("d",1,date) &" " &"8:00:00"
sqlstr="select station,vdatetime,data from vTable where vdatetime between initialdatetime and datetomorrow group by datetime,station"
just add loops to calculate their value querried
TIPS in using sql server: don't ever use a fieldname that is similar to its function like (date,time) just select another fieldname..
Try it !
I guess you're developing a computer cafe the what they call rental monitoring system..
vyx
---------------------------------------------------------
"Genius is 1 percent inspiration but it is 99 percent perspiration"
by Thomas A. Edison
|