Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 22nd, 2004, 10:01 AM
keerthi_007 keerthi_007 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 keerthi_007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Immediate Help Needed

The requirement is something like this.I am using the stored procedure to develop the crystal report.
Requirement:check if current/today's date is in between startdate & enddate,if it is depending on the parameter(w-means current week,
Y-means year to date,if parameter is blank then defaultly u need to display current week).I dont know how to map this parameter value w/ which column.
we need to find the starting date of the week(first day of the week is monday & lastday of the week is sunday) & display the records
for that particular week.if its yearly then its should diplay the data for that fiscal year(fiscal year starts from
oct 1 to sep 30),eg we are now in nov,todays date is 18th when the parameter is Y then it should display the records from oct 1
to today's date.


SELECT
TaskOrder.CustomerCode,
CustomerInfo.CustomerName,
ModProjTaskDetail.DOLCode,
TaskOrderAwards.PPStartDate,
TaskOrderAwards.PPEndDate,
ModProjTaskDetail.SkillCategory, COUNT(*) AS Plsmts_Total
FROM TaskOrderAwardMods

INNER JOIN TaskOrderAwards
ON TaskOrderAwardMods.TaskOrderAwardNum = TaskOrderAwards.TaskOrderAwardNum
INNER JOIN ModProjTaskDetail
ON TaskOrderAwardMods.TaskOrderModNum = ModProjTaskDetail.TaskAwardModNum
INNER JOIN TaskOrder
ON TaskOrderAwards.TaskOrderNum = TaskOrder.TaskOrderNum
INNER JOIN CustomerInfo
ON TaskOrder.CustomerCode = CustomerInfo.CustomerCode

WHERE (TaskOrderAwards.PPStartDate <= GETDATE()) AND (TaskOrderAwards.PPEndDate >= GETDATE())

GROUP BY
TaskOrder.CustomerCode,
CustomerInfo.CustomerName,
ModProjTaskDetail.DOLCode,
TaskOrderAwards.PPStartDate,
TaskOrderAwards.PPEndDate,
ModProjTaskDetail.SkillCategory

Reply With Quote
  #2  
Old November 22nd, 2004, 06:18 PM
MrData MrData is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Sacramento, California, USA
Posts: 13 MrData User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 11 sec
Reputation Power: 0
Not too hard, but...

You'll need to use some datetime manipulations. Remember, when you populate a datetime with a string and leave out the time part, you get a datetime of midnight at that date.

so for the weekly one, you'll want to do something like this:

Code:
  SET DATEFIRST 1 --First day of week now monday
  
  Declare @StartDate datetime
  
  IF @IntervalType = 'w'
  BEGIN
    Select @StartDate = convert(varchar(8), dateadd(day, -(datepart(dw, getdate())), getdate()), 112)
  
  END
  
  IF @IntervalType = 'Y'
  BEGIN
   Select @StartDate = 
    case when month(getdate()) >= 10 then '10/1/' + Year(getdate())
     else '10/1/' + (Year(getdate()) - 1)
  END
  --Et cetera, with a new where clause that reflects this
  
  


Also, to set a default parameter in a sproc is easy. Just give it a value, like so:

Code:
  
  CREATE PROCEDURE usp_some_proc @IntervalType char(1) = 'w'
  as
  BEGIN
  
  


... to give the @IntervalType a default value of 'w'.

Hope this helps,
Steve

Last edited by MrData : November 22nd, 2004 at 06:20 PM. Reason: screwed up the sproc declaration (no datatype)

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Immediate Help Needed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek