Getting parts of a date

SimonW18272
SimonW18272 New Altair Community Member
edited November 5 in Community Q&A
Hello together.

I got a question. When I want to create a new attribute I have the following problem.
I have a date which is in forma contaning month, day, year, time.
However I just want to extract the Month and the year so that the format is YYYY:MM

I found in the internet only the 

date_get(Att1,DATE_UNIT_MONTH)

Operator.

However I am now courious if it is easily possible to get also the year within this operator so that I have the YYYY:MM of the att1

My operator should look like
date_get(Att1,DATE_UNIT_YEAR_MONTH)
However it isnot possible this way.

Can someone help me to keep the date format (not nominal/...) and just the year and month in one attribut






Answers

  • BalazsBarany
    BalazsBarany New Altair Community Member
    Hi!

    Year and month are two numerical attributes. How would you represent them in one numerical attribute?

    If you need them in one attribute, you need to convert them to a nominal attribute. The formula for that is date_str_custom(Att1, "yyyy:MM").

    Regards,
    Balázs
  • SimonW18272
    SimonW18272 New Altair Community Member
    Thanks a lot! By adding the sort operator I can finally use this to see a monthly overview of my data :) Thanks a lot!!!