Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date calculations

Status
Not open for further replies.

cmarch1

MIS
Apr 5, 2001
41
US
I'm trying to calculate a datetime field with the month and day static but the year changes...

for instance @BudgetDate = '10/01/2001'
but the year changes each fiscal year
where
year(getdate()) = correct year because this procedure will only be run at the begining of a new fiscal year

I've tried different combinations of date functions but can't come up

Any suggestions
 
How about using the function dateadd
E.g.

declare @Date as varchar(20)
set @date = '10/01/2001'
set @date = DATEADD(year, 1, @Date)

This adds 1 year to 10/01/2001

-Log


 
Thanks...that's good for next year's budget cycle.
But what about the next years.
This code relates to a Revenue Tracking program and needs to be hidden to the average user so its calculated automatically.
The code you gave me will have to be updated every year and that won't help me right now.
 
figured it out looking back on other posts
thanks.....


Declare @test integer
Declare @budgetdate datetime
Set @test = year(getdate())
select @budgetdate = Convert(datetime, convert(varchar(4),@test) + '10' + '01')
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top