Extract Year and Categorize by year

I need to be able to take a date value and extract the year from it so that I can categorize the records in a view based on the year of submission. So Far when I try to use extract the date I get an error in the view.

This is the code I am using to try and extract the year. Sometimes their will be no value for DateClosed.

@Year(DateClosed)

Subject: Record Count - Column Total

Just figured out that I needed to add a one to the formula for the column so that it has a value to count.

Is that correct or is their a better way? What if I wanted to sort the records total into categories broken down by year?

Subject: RE: Record Count - Column Total

A better way is to move your @Year(DateClosed) out of the column formula and make it a computed field in your form/documents.The main benefit is performance (having date/time-related view column formula is bad);

Also, you can use this item for other purposes, if needed.

HTH,

Simeon

Subject: RE: Record Count - Column Total

The point of Simeon’s comment is the horsepower required to figure dates in a view I presume. But, the @Year(DateClosed) should, in fact, bring the year forward it the DateClosed field is a datetime field. It there are documents that do not have a date in that field- you should do error checking- @If(DateClosed <>“”;@year(DateClosed);“”)

Subject: Record Count - Column Total - SOLVED

Yes I ran into that issue. Here is what I ended up doing.

@If(@Text(DateClosed)=“”;“Date Closed Not Entered”; @Year(DateClosed))

Subject: RE: Record Count - Column Total

Using @Year(DateClosed) should not hurt anything performance wise because the Time/Date in the DateClosed field is fixed (already calculated), unlike using @Now, @Today, @Yesterday, @Tomorrow, etc. which are real-time and constantly change.

Subject: RE: Record Count - Column Total

I agree; @Year on a fixed value is harmless, unlike the dreadfull @Now, etc.Still, I believe storing such data in the documents is (in most cases) a better practice.

Moving view formula to the save event spreads the “horsepower” in time;

A little more storage, but a little faster view refresh…