Query Previous year records

Is there any way to get the records of Asset that have InstallDate of last year. I am doing this way.

Integer preYear = system.today().year()-1;

preYearAssetList = [Select id from Asset Where installDate.year() = preYear];


Have you tried the below

system.debug('***'+[Select id from Asset Where installDate = LAST_YEAR]);

For current year it will be THIS_YEAR

For Next year it will be NEXT_YEAR

Check all combinations in this article

Category: apex Time: 2016-07-29 Views: 5

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.147 (s). 12 q(s)