LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Date to String Conversion

    Employee
    Posted 04-22-2013 00:31

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Jensen

    I have a date field and I'm hoping to convert it into a string field with the format: "m YY"
    e.g. 31-01-2013 should return me "Jan 13"

    I can do it using nested IFs on dateField.month() but I am hoping there's a more elegant way of doing this.

    Thanks in advance!


  • 2.  RE: Date to String Conversion

    Employee
    Posted 04-22-2013 17:48

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: mlowe

    One approach might be:

    if firstExec then { dl = list("","Jan","Feb","Mar","Apr","May","Jun","Jul", "Aug","Sep","Oct","Nov","Dec") }

    emit dl.getItem(dateValue.month()).str() + " " + dateValue.year().str().substr(2,2) as "newDateFormat"


  • 3.  RE: Date to String Conversion

    Employee
    Posted 04-22-2013 21:12

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    If you have many thousands of records to process, you MAY find this to be slightly faster:

    emit substr("...JanFebMarAprMayJunJulAugSepOctNovDec",d ateValue.month()*3,3)
    + " " + dateValue.year().str().right(2) as "newDateFormat"


  • 4.  RE: Date to String Conversion

    Employee
    Posted 04-23-2013 22:47

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Jensen

    Thanks both.
    I prefer your approaches to nested if.

    Just a thought, it might be more convenient if Brainscript can take care of this instead.
    Cheers!


  • 5.  RE: Date to String Conversion

    Employee
    Posted 04-24-2013 06:33

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rboccuzzi

    This has been captured as enhancement request #4841.

    Cheers
    Rich