{"id":1663,"date":"2009-09-02T12:42:19","date_gmt":"2009-09-02T07:42:19","guid":{"rendered":"http:\/\/www.chiragmehta.info\/chirag\/?p=1663"},"modified":"2009-09-02T12:42:19","modified_gmt":"2009-09-02T07:42:19","slug":"salesforce-apex-covert-datetime-to-date","status":"publish","type":"post","link":"https:\/\/www.chiragmehta.info\/chirag\/2009\/09\/02\/salesforce-apex-covert-datetime-to-date\/","title":{"rendered":"Salesforce : Apex : Covert DateTime to Date"},"content":{"rendered":"<p>I look through the documentation and didn&#8217;t see a system method that converts a date time field to a date. There is one for formula fields but is there one for Apex?<\/p>\n<p>Solution : Just create a date newInstance() and pass in just the year,month,day from the dateTime object.<\/p>\n<blockquote><p>Datetime dateTimetemp = System.now();<\/p>\n<p>Date dateTemp = Date.newInstance(dateTimetemp.year(),dateTimetemp.month(),dateTimetemp.day());<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>I look through the documentation and didn&#8217;t see a system method that converts a date time field to a date. There is one for formula fields but is there one for Apex? Solution : Just create a date newInstance() and pass in just the year,month,day from the dateTime object. Datetime dateTimetemp = System.now(); Date dateTemp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[169],"class_list":["post-1663","post","type-post","status-publish","format-standard","hentry","category-salesforce","tag-salesforce","post-preview"],"_links":{"self":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/1663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/comments?post=1663"}],"version-history":[{"count":1,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/1663\/revisions"}],"predecessor-version":[{"id":1664,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/1663\/revisions\/1664"}],"wp:attachment":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/media?parent=1663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/categories?post=1663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/tags?post=1663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}