Results 1 to 3 of 3

Thread: MonthName from Date

  1. #1
    Contributor
    Join Date
    Apr 2013
    Location
    Warrington
    Posts
    13

    Default MonthName from Date

    Hi - is it even possible to create a monthName from a date field?

    I have a date column:

    USAGE_CALL_DATE
    2017-03-27
    2017-03-27
    2016-02-01

    I would like to convert to the following but then also have the ability to SORT as I would with the actual date:

    MAR-2017
    MAR-2017
    FEB-2016

    I have managed to create a node which generates a value which is the same as the requested output but it is a string format so am unable to sort in a date order.

    thanks

    Martin

  2. #2
    Lavastorm Employee stonysmith's Avatar
    Join Date
    Nov 2006
    Location
    Grapevine Tx
    Posts
    757

    Default

    I would use this:

    Code:
    m=USAGE_CALL_DATE.month()
    mmm="xxxJANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC".substr(m*3,3)      #note the xxx as month(0)
    emit mmm + "- " + USAGE_CALL_DATE.year().str() as Usage_Call_Month
    However, you're not going to be able to sort on that column. April would always come first.
    I would suggest keeping both columns in the data, sort on USAGE_CALL_DATE (the full date), and then remove that column just before output if you wish.

  3. #3
    Contributor
    Join Date
    Apr 2013
    Location
    Warrington
    Posts
    13

    Default

    Thanks Stony, i will go with inclusion of the full date to enable the sort. Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •