Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to create new view for my list. The list contains a column called Year, which is a number and contains, as name suggests, year. Eg.:

2012
2011
2010
2009

I would like create a view, where I would display only last 3 years. The <Query> element of my List Definition is:

<Query>
  <Where>
    <Geq>
      <FieldRef Name="Year" />
      <Value Type="Number"> ???? </Value>
    </Geq>
  </Where>
</Query>

And it gets tricky here. How to write a condition, that a number should be greater that current year minus 3? I thought it would work like in UI, so I could use:

YEAR([Today])-3
share|improve this question
add comment

1 Answer 1

Maybe you can you use the OffsetDays attribute for this? (all depends on how exact the 3 years should be) as there is no way you can do leap years this way. Here is how do it using days in case.

<Query>
  <Where>
    <Geq>
      <FieldRef Name="Year" />
         <Today OffsetDays="-1" /> //amount of days to subtract
    </Geq>
  </Where>
</Query>

Hope this helps

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.