View Selection - Get the number of years

Hi All,

I have a form with a date field which stores only month and year ie. 12/2001.

How can I write in the View Selection to select the record with the date field which is more than 5 years? For example, now is 05/2005, so I need to display all the record with the date < 05/2000.

How can I do it?

Thanks a lot.

Subject: View Selection - Get the number of years

adjustedYear:=@Adjust(@TextToTime(“Today”);-5;0;0;0;0;0);SELECT Form=“FormName” & @Year(@Created) <= @Year(adjustedYear)

change FormName & @Created as required

cheers !!

Ashish

Subject: View Selection - Get the number of years

Some advice: don’t do that. Store dates as dates, and if you need to display a weird format, use the “custom” option for the field widget setting or compute text for display as needed. What matters is that the date value you use for searches, sorting and computation remains a proper date value. Otherwise, you will forever be at the mercy of local settings when trying to do conversions.

If the date were a date, then you could use the following selection formula:

@Adjust(DateField;0;0;1-@Day(DateField);0;0;0) < @Adjust(@Adjust(@Today;0;0;1-@Day(@Today);0;0;0);-5;0;0;0;0;0)

Subject: RE: View Selection - Get the number of years

Both way also don’t work, no record displayed. My date field is in Date/Time format with only month and year.

Does it matter?

Subject: RE: View Selection - Get the number of years

No, it shouldn’t matter at all. If it is actually a date (by that, I mean the values in the documents, not the setting on the form – you will need to examine the documents using the Document Properties dialog, second tab), then the solutions given should work. If what is stored in the documents is text, it won’t – you would need to convert the value to a date in your view selection formula.