borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Using Access 2000 files with VB6)Next Topic (An activex that cud change list items) New Topic New Poll Post Reply
AndreaVB Forum : Database : SQL statement from today to next day
Poster Message
fuji_su
Level: Professor


Registered: 26-08-2005
Posts: 73

icon SQL statement from today to next day

need help on SQL statement. I need to query data from 8 am today till 8 am on the next day.and sum all the data. Any ideas?

db field:
station | date  | time  | data

[Edited by fuji_su on 22-07-2007 at 01:32 AM GMT]

____________________________
-fuji-

21-07-2007 at 05:29 PM
View Profile Send Email to User Show All Posts | Quote Reply
VYX
Level: Professor


Registered: 16-12-2005
Posts: 70
icon 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

23-07-2007 at 02:51 AM
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: SQL statement from today to next day

Hi,
We need to know the actual format of the data in your table.. not just the field name.

What datatype are your fields?
Sample of some records would be good too
Regards,
Kieron


____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

23-07-2007 at 11:30 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : SQL statement from today to next day
Previous Topic (Using Access 2000 files with VB6)Next Topic (An activex that cud change list items) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder