You need to sign in to do that
Don't have an account?
Kitpith
Get Month,Year from Date
Hello,
Could anybody tell me in one field in object, Date is stored. So i need to get record showing Month for that date . Is there any method like oracle i.e. to_char(StoredDate,MM)
Or any method like Month(StoredDate).
Hello,
You don't need Apex for this, you could just create a new Custom field of type Forumla and use this syntax : MONTH(date)
for more : https://help.salesforce.com/htviewhelpdoc?id=customize_functions_i_z.htm&siteLang=en_US#MONTH
Hello elmoussaoui,
I am trying To Get data In Query from Object In Apex code so don't need to work with Custom Field.
If you work with workbench Then below Is the query
SELECT RequestDate__c FROM Object_Name
Need To Get Month from that object Query
If all you're trying to do is get the month / year from a Date in Apex this will work:
Essentially you use the month() and year() method on the Date objects... see here for more information about the Date object in Apex:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_date.htm
SELECT CALENDAR_MONTH(CreatedDate), SUM(Amount)
FROM Opportunity
GROUP BY CALENDAR_MONTH(CreatedDate)