Constituencies and time

This time I'm working on a piece of logic to populate constituencies.  I'm modifying a stored procedure to populate the constituency of a given customer based on associations where the end_dt of said association is >= the end of the current fiscal year (7/31/2009 - in this case).  I'm quite sure it can be written so that for any given date the procedure is run the exact date of the end of the current fiscal year can be calculated without having to use a reference table.  Am I making sense?

I'm sure this is a first year programming problem, but I can't seem to remember the solution.  Unfortunately, I have a practially non-existent parietal lobe or something.

BONUS TRIVIA OFFERING:  Regarding our current 1 trillion dollar federal budget; 1 trillion dollars would buy a $3 latte for 23 generations of your children every day for life.

Parents
  • I doubt this is the most elegant way to accomplish this, but is this sort of what you wanted?

    select CASE   
            WHEN Getdate()< CAST('8/1/'+ cast(datepart(yyyy, getdate()) as varchar(4)) as datetime)
            THEN CAST('7/31/'+ cast(datepart(yyyy, getdate()) as varchar(4))+' 23:59:59' as datetime)
            Else CAST('7/31/'+CAST( datepart(yyyy, getdate())+1) as varchar(4))+' 23:59:59' as datetime)
    End

Reply
  • I doubt this is the most elegant way to accomplish this, but is this sort of what you wanted?

    select CASE   
            WHEN Getdate()< CAST('8/1/'+ cast(datepart(yyyy, getdate()) as varchar(4)) as datetime)
            THEN CAST('7/31/'+ cast(datepart(yyyy, getdate()) as varchar(4))+' 23:59:59' as datetime)
            Else CAST('7/31/'+CAST( datepart(yyyy, getdate())+1) as varchar(4))+' 23:59:59' as datetime)
    End

Children
No Data