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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get 1 year prior in SQL

Status
Not open for further replies.

teddysnow12

Programmer
Aug 12, 2011
30
US
Hi,

I need syntax in SQL to get 1 year prior for a given year.


Thanks!
 
it is saying that dateadd is an invalid identifier.
The field related to this is rptg_yyyymm.
and teh value is like this '2008-10' (yyyy-mm)
the datatype is string.

do you think first i need to convert it into date format and then calculate the prior year?
 
teddysnow12,

Are you in the correct forum? I noticed your earlier thread was not specifically a Crystal Reports question. If you are looking for SQL solutions, there are forums specifically devoted to this.

-LB
 
Yes - I believe you need to do that first:
Select convert(datetime, dateadd (year, -1, @yourdate), 101)
 
I will post the questions in SQL threads.

sorry for inconvinience.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top