Something like this?

if (select datediff(d,startdate,enddate)) <= 366
begin
select
dateadd(d,datediff(d,startdate,enddate)/4,startdate) as Q1,
dateadd(d,datediff(d,startdate,enddate)/4*2,startdate) as Q2,
dateadd(d,datediff(d,startdate,enddate)/4*3,startdate) as Q3,
dateadd(d,datediff(d,startdate,enddate)/4*4,startdate) as Q4
end
else
begin
select message='exceeds year'
end

~Dina

  ----- Original Message -----
  From: Kristen Winsor
  To: SQL
  Sent: Friday, May 21, 2004 1:50 PM
  Subject: Identify" Quarter" Start /QuarterEnd if period is less than 1 year

  Hi all

  Is there a function that will determine the next "quarter's date" in the
  following example:

  USER INPUT
  StartDate: 5/01/2004
  EndDate: 03/01/2005
  Payment Option: Quarterly

  Since this is a 10 month period I need to return the date every 2.5
  Months from the startDate to the endDate
  End result would be:
  Q1 = 7/15/2004,
  Q2 = 9/1/2004,
  Q3 = 12/15/2004,
  Q4 = 3/1/2005

  I am thinking there must be a better way then I have been playing w/ the
  last hour
  Determine the number of days from start to end if over 366 then
  If quarterly count the number of months from start to end then divide by
  4
  Then .......

  May thanks to any assistance, which you may think of :)

  Thank you and best regards,

  Kristen A. Winsor
  Intranet, Database Administrator
  Falvey Cargo Underwriting
  213 Robinson Street
  Wakefield, RI 02879
  401 675 9266 Direct
  401 792 0144 Main
  401 792 0004 Fax
  [EMAIL PROTECTED]

  This communication, including any attachments, is confidential and is
  protected by privilege. If you are not the intended recipient, any use,
  dissemination, distribution, or copying of this communication is
  strictly prohibited. If you have received this communication in error,
  please immediately notify the sender by telephone or email, and
  permanently delete all copies, electronic or other, you may have. The
  foregoing applies even if this notice is embedded in a message that is
  forwarded or attached
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to