Activity Forums Salesforce® Discussions How to change the text field entered data into a particular format?

  • Abhinav

    Member
    August 1, 2016 at 1:44 pm

    Hi Pranav,

    If you're doing this in a Field Update :-

    DATE(VALUE(LEFT(TextField__c, 4)), VALUE(RIGHT(TextField__c, 2)), 1)

    In apex code use the following -

    String dateString = '2014-09';
    Integer year = Integer.valueOf(dateString.subString(0, 4));
    Integer month = Integer.valueOf(dateString.subString(5));
    Date d = Date.newInstance(year, month, 1);

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos