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.  Convert CCYY-MM-DD to MMM-YY?

    Employee
    Posted 06-18-2015 05:11

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

    Originally posted by: lauraw_21

    Can anyone help me convert the above?


  • 2.  RE: Convert CCYY-MM-DD to MMM-YY?

    Employee
    Posted 06-18-2015 05:49

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

    Originally posted by: ryeh

    There is probably a more elegant way to format the date, but this example works. It basically assigns the month number to the appropriate abbreviation.
    Attachments:
    formatDate.brg


  • 3.  RE: Convert CCYY-MM-DD to MMM-YY?

    Employee
    Posted 06-18-2015 06:09

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

    Originally posted by: lauraw_21

    Worked a treat, thank you although it returns them as strings and I need them as dates?


  • 4.  RE: Convert CCYY-MM-DD to MMM-YY?

    Employee
    Posted 06-18-2015 07:56

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

    Originally posted by: stonysmith

    It's not necessarily more "elegant", actually more "old school", but it is significantly faster than a 12-way switch()....

    MMM = "JanFebMarAprMayJunJulAugSepOctNovDec".substr(myda te.month()*3-3,3)

    It does require the field "mydate" to be a date() datatype.


  • 5.  RE: Convert CCYY-MM-DD to MMM-YY?

    Employee
    Posted 06-19-2015 08:06

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

    Originally posted by: ryeh

    Hi, Laura. Think of the format in which Lavastorm keeps track of dates as an arbitrary format. We happen to show it as CCYY-MM-DD in the data viewer. If you need to operate on dates, i.e. compare dates (what's before/after), get differences, offset dates, then definitely keep those fields as date types. When all is said and done, you may want to publish out to a different format. That's when you would convert to a MMM-YY format. But that would now be a string, as you noted.

    So in short, if you care about how dates are formatted, save that format conversion for the last step!

    As a side note: Stony, that approach was definitely more elegant and more clever. And as you said, much much faster!