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 string conversion to date, returning wrong month/year

    Employee
    Posted 05-29-2015 02:10

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

    Originally posted by: tris9000

    hi,

    my data has a string date as "Jan 2015". I'm using the following script to convert this string into a date:

    emit 'Month'.date("m CY") as "Month"

    However, the date returned is actually a month earlier than it should be (so my Jan 2015, becomes 31/12/2014). It seems to be automatically creating the last day in the month, which isn't a problem to me

    Any help, greatly appreciated

    Best regards

    Tris


  • 2.  RE: date string conversion to date, returning wrong month/year

    Employee
    Posted 05-29-2015 06:35

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

    Originally posted by: stonysmith

    Personally, I'd do it this way:

    emit ("01 "+'Month').date("d m CY") as "Month"

    This would add a date of the 1st to the value, and should keep it within the month you expect.


  • 3.  RE: date string conversion to date, returning wrong month/year

    Employee
    Posted 05-29-2015 08:33

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

    Originally posted by: tris9000

    Thanks, I tried that but getting below error now:

    cannot parse value '01 Jan 2015' with format 'd m CY'

    thanks for any help you can offer

    Tris


  • 4.  RE: date string conversion to date, returning wrong month/year

    Employee
    Posted 05-29-2015 08:49

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

    Originally posted by: stonysmith

    Sorry.. it should have been a capital D

    emit ("01 "+'Month').date("D m CCYY") as "Month"

    Place your cursor on the "date" keyword and hit F1 to see the full list of format options