Skip to main content
November 23, 2023
Question

Required dropdown to show date in MMM-DD format

  • November 23, 2023
  • 5 replies
  • 0 views

Hi All,

I got one change request, to show the date in "MMM-DD" format for the current calendar year, I think this can be achieved by concatenating two dropdowns (when user selects month in the first dropdown and  second drop down should show days in the months) and  I need to write some code to do that.

Can anyone please guide me in achieving the same? Thanks in advance.

We are using Appian 23.3 version. 

Thanks

5 replies

sriramk5349
November 23, 2023

Hi [mention:29a1760260ad48a49ff5bff26b63d68a:e9ed411860ed4f2ba0265705b8793d05] ,

Since you said it is current calendar year, You can use below code. But if you want year also to be dynamic, then create another dropdown for year also.

if you have the date already then use text(date,"mmm-dd")

a!localVariables(
  local!months:{"January","February","March","April","May","June","July","August","September","October","November","December"},
  local!monthSaved,
  local!daySaved,
  {
    a!dropdownField(
      label: "Month",
      placeholder: "Select Month",
      choiceLabels: local!months,
      choiceValues: enumerate(length(local!months))+1,
      value: local!monthSaved,
      saveInto:{
        local!monthSaved,
        a!save(local!daySaved,null)
      } 
    ),
    a!dropdownField(
      label: "Day",
      placeholder: "Select Day",
      choiceLabels:if(
        a!isNullOrEmpty(local!monthSaved),{},
        enumerate(daysinmonth(local!monthSaved,year(today())))+1
      ),
      choiceValues: if(
        a!isNullOrEmpty(local!monthSaved),{},
        enumerate(daysinmonth(local!monthSaved,year(today())))+1
      ),
      value: local!daySaved,
      saveInto:{
        local!daySaved
      } 
    ),
    a!richTextDisplayField(
      label: "Saved Date",
      labelPosition: "JUSTIFIED",
      value: {
        a!richTextItem(
          text: text(date(year(today()),local!monthSaved,local!daySaved),"mmm-dd")
        )
      },
      showWhen: and(a!isNotNullOrEmpty(local!monthSaved),a!isNotNullOrEmpty(local!daySaved))
    )
  }
)

November 23, 2023

Thank you very much for your reply. This will help.

prakhars0731
November 23, 2023

If it is only about the MMDDYYYY format than you can change your env settings that will work.

November 23, 2023

Thank you very much for your reply, We dont have permission to change env settings. I will check with Admin.

prakhars0731
November 23, 2023

ok