 |
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

May 7th, 2004, 03:45 AM
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
sql - comparing current time
Hi,
I have 1 table with 3 column(session(eg:1),start(eg: 8:00:00 AM),end (eg:10:00:00 AM)
I want to determine which session I'm in now by using sql statement,
just like this :
time = date.now
"select session from table1 where time > start and time < end"
Is it works ? or there is another way to make it?..thanks
__________________
 Suzila
|

May 7th, 2004, 10:32 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
You could also use BETWEEN .. but yes- that pseudo code looks about right.
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|

May 11th, 2004, 02:01 AM
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yes, the logic is seem like to correct but the main problem are, the sql statement cannot compare the 'time' with 'start'
time = '8:00:00 AM'(current time) so do start = 8:00:00 AM( database)
('ive try use convert and cast)
anyone knows? i'm using sql server..thanks a lot
|

May 11th, 2004, 08:36 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
what do you mean it can't compare it.. what kind of error are you getting?
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|

May 11th, 2004, 07:54 PM
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yes, it can't compare it.
I didn't get any error but it didn't produce any output..
I'm using convert.. like this : convert(datetime,time,9)
9 - because i'm using AM and PM
|

May 12th, 2004, 08:38 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Please paste your sql statement here for review.
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|

May 13th, 2004, 03:59 AM
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
column 1 : session (eg: 1),
column 2 :start (eg: 8:00:00 AM),
column 3: end (eg:10:00:00 AM)
t= date.now
SELECT session, CONVERT(datetime, start, 9) AS start, CONVERT(datetime, end, 9) AS end
FROM dbo.sessi
WHERE (end > (CONVERT(datetime, t, 9))) AND (start < =(CONVERT(datetime, t, 9)))
|

May 14th, 2004, 12:05 AM
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i just solve my problem,
my solution like this
SELECT session
FROM dbo.sessi
WHERE
(start < CONVERT(varchar(30), GETDATE(), 114)) AND (end > CONVERT(varchar(30), GETDATE(), 114))
thank you for help me..:D
|
|
 |