Wrox Programmer Forums
|
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
 
Old May 7th, 2004, 03:45 AM
Authorized User
 
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to suzila
Default 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
 
Old May 7th, 2004, 10:32 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You could also use BETWEEN .. but yes- that pseudo code looks about right.

Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
 
Old May 11th, 2004, 02:01 AM
Authorized User
 
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to suzila
Default

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
 
Old May 11th, 2004, 08:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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
 
Old May 11th, 2004, 07:54 PM
Authorized User
 
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to suzila
Default

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






 
Old May 12th, 2004, 08:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Please paste your sql statement here for review.

Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
 
Old May 13th, 2004, 03:59 AM
Authorized User
 
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to suzila
Default



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)))





 
Old May 14th, 2004, 12:05 AM
Authorized User
 
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to suzila
Default

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
Current Date and Time in XSLT devMc XSLT 6 October 21st, 2007 04:49 AM
getting current date and time in xslt 1.0 ashyabhi_hp XSLT 1 September 24th, 2007 03:17 AM
Gridview, Eval and Current Time timeware ASP.NET 2.0 Professional 3 September 20th, 2006 06:06 AM
comparing date/time fields on form validation Lucy Javascript How-To 1 June 20th, 2006 09:22 AM
Check to See if Current Time is between hours mvollmer Classic ASP Professional 5 July 28th, 2004 07:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.