Skip to content

Instantly share code, notes, and snippets.

@gdmarsh
Created August 7, 2014 12:11
Show Gist options
  • Save gdmarsh/ab5b799dfe771e6cda5b to your computer and use it in GitHub Desktop.
Save gdmarsh/ab5b799dfe771e6cda5b to your computer and use it in GitHub Desktop.
Anonymous script to print out list of date fields from a specified sObject
Map<String, Schema.SObjectField> fieldMap =
Schema.SObjectType.Account.fields.getMap();
List<String> fieldNames = new List<String>();
for(Schema.SObjectField fld : fieldMap) {
Schema.DescribeFieldResult res = fld.getDescribe();
if(res.getType() == Schema.DisplayType.DATE) {
fieldNames.add(res.getName());
}
}
fieldNames.sort();
for(String s : fieldNames) {
System.debug(LoggingLevel.INFO, s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment