Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 9th, 2006, 03:19 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Byock
Default help with SQL dates

hello,

Please help with my stored proc

I need to be able to select all books not yet return for more than 30 minutes, 2 hour and 3 hours repsectively

the following is my code....it works fine but then if my current hour is 1PM...it will display the books borrowed in 12:55 PM, which should not be shown becuase it is borrowed below or less than 30 minutes....How will i check the difference between my two dates with regards to its AM/PM?

alter procedure dbo.getBooksNotReturn
(
@search nvarchar(1024) = ''
)
Select titles, isbn, dateBorrowed, status from dbo.books
where
(@search = ''
    or (status <> 'Returned') and 1 =
   (Case
      When @search = '30m' and (datediff(hh, dateBorrowed,
          CONVERT(CHAR(20), GETDATE(), 22)) > 0.5) then
        1
      When @search = '1h' and (datediff (hh, dateBorrowed,
          CONVERT(CHAR(20), GETDATE(), 22)) > 1) then
        1
      When @search = '3h' and (datediff (hh, dateBorrowed,
          CONVERT(CHAR(20), GETDATE(), 22)) > 3) then
        1
      else
           0
   End)
)
End

Reply With Quote
  #2 (permalink)  
Old March 23rd, 2006, 12:58 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to demiwolf
Default

Just curious, why are you converting the current date to CHAR? I don't have a solution but wondered if that probably has something to do with your issue.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting Dates in SQL meichmann SQL Server 2000 5 April 18th, 2005 10:58 AM
SQL dates - Problem malecumbria Classic ASP Databases 4 February 16th, 2005 01:18 PM
SQL dates in American lic023 Access VBA 4 July 8th, 2004 03:06 AM
sql for searching in between given dates reshmisworld Classic ASP Databases 1 July 26th, 2003 10:23 AM
International Dates in SQL owain SQL Language 2 June 13th, 2003 03:12 PM



All times are GMT -4. The time now is 09:03 PM.


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