Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 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 November 8th, 2006, 09:03 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default Chapter 1 Procedure Help

Ok, so I realize this isn't a SQL book, but it would be helpful if someone could help out with the procedure below. Just trying to get a handle on how the code gets the result set it does.

In the following...where is DAY defined? Is that just an internal typecase function...or is there a DAY function somewhere I am not seeing it. Also--is the first three lines generic for any procedure I would need to write? Lastly, what is the "106" parameter passed in the CONVERT function?


*********************************************
Get Days With Events

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[GetDaysWithEvents]
    (
        @DiaryId int,
        @EventFromDate datetime,
        @EventToDate datetime
    )

AS
SET @EventFromDate = CONVERT ( datetime , @EventFromDate , 106)
SET @EventToDate = CONVERT ( datetime , @EventToDate , 106)
SET @EventToDate = DATEADD(d, 1, @EventToDate)

SELECT DAY(EventDate)
  FROM DiaryEvent
  WHERE DiaryId = @DiaryId AND
            (EventDate >= @EventFromDate AND EventDate < @EventToDate)
GROUP BY DAY(EventDate)
ORDER BY DAY(EventDate)


Thanks so much,
Rob

 
Old November 9th, 2006, 02:35 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Rob,

1. DAY is a built-in SQL Server function that returns an integer representing the day datepart of the specified date.

So, SELECT DAY(GetDate()) would return 9 for today's date (GetDate() is a function that returns the current date and time)

2. The first three lines aren't required in a procedure you write yourself. However, if you script the procedures using SQL Server, this is what you get. They're basically defaults to ensure the procedure ends up the same as it was in the system when you scripted it. Don't bother typing this in every time you create a procedure.

3. The number 106 is a parameter to the CONVERT function that tells SQL Server to convert the date and time in a dd mon yyyy format.

Take a look at SQL Server's Books Online for more information about 1 and 3. For 1, the keyword is DAY, for 3 the keyword is CONVERT (and CAST) and you'll find a list with all other possible numbers you can pass to Convert.

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old November 9th, 2006, 10:05 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default

Imar,

As always, thank you so much for your time and help!

Kind Regards,
Rob






Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 2 - End of chapter exercises whizzkid1892 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 30th, 2008 12:02 PM
Procedure nick1005 MySQL 2 October 18th, 2007 08:41 AM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM





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