•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 456,531 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,890 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 1039 | Replies: 1
![]() |
•
•
Join Date: Oct 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
I have a VB program that needs to count number of events between two datetime values.
Something like this:
SELECT COUNT(*) FROM Report WHERE WeigthTime BETWEEN "Time1" AND "Time2"
Time1 is now. I get it with "SELECT GETDATE()"
I need to calculate Time2 by decrementing it for X hours. X is insertred in VB Form.
Is there some operators for datetime format?
Please help.
Best regards
Something like this:
SELECT COUNT(*) FROM Report WHERE WeigthTime BETWEEN "Time1" AND "Time2"
Time1 is now. I get it with "SELECT GETDATE()"
I need to calculate Time2 by decrementing it for X hours. X is insertred in VB Form.
Is there some operators for datetime format?
Please help.
Best regards
•
•
Join Date: May 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
To decrement a datetime by a number of hours you can use the DATEADD function. Rather than using a positive number ,which would increment datetime, use a negative number.
http://technet.microsoft.com/en-us/l.../ms186819.aspx
Hope that helps.
James
To decrement a datetime by a number of hours you can use the DATEADD function. Rather than using a positive number ,which would increment datetime, use a negative number.
http://technet.microsoft.com/en-us/l.../ms186819.aspx
Hope that helps.
James
![]() |
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Default current datetime for column (MS SQL)
- datetime/ i need only date (MS SQL)
- dateTime picker (ASP.NET)
- datetime format in ms sql (MS SQL)
- insert datetime into the database (C#)
- overloading increment/decrement operators (C++)
- Access AutoNumber Decrement (Visual Basic 4 / 5 / 6)
Other Threads in the MS SQL Forum
- Previous Thread: Complicated SQL SELECT Statement - NEWBIE
- Next Thread: row count


Linear Mode