How to display only month and year in a date field?

Student1
Tera Contributor

Hello,

I have the following date field. However, I want the user to be able to select the month and the year and not the day too.

So, instead of today date, the user would select November 2020.

find_real_file.png

However, I don't want to do it with a dropdown list, but with a date picker.

Any ideas?

 

1 ACCEPTED SOLUTION

Hi,

So you created 2 drop down variables.

So you need to concatenate Month and Year in the Short Date

If yes then you would require 2 onchange client scripts 1 for Month and another for Year

then you can set the value by joining in the Short Date

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Jaspal Singh
Mega Patron
Mega Patron

Hi,

 

Surely you would have gone through other links but as of now it is available OOB & if customized would require additional efforts & would be a fully custom solution.

Unfortunately, I couldn't find a solution to this. 

If I need to make a customized solution,

what do I need to create?? A UI macro??

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

For custom solution

Please create 2 variables of type drop down

1st having drop down values as months Jan to December

2nd having drop down values year from 2001 to 2020 or depending on your client requirement

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hey @Ankur Bawiskar,

I followed your suggestion.

I have the following form, I would like to populate the field date based on selected month and year.

In the following example, the date must be "January 2018".

So, I guess that I need to create an onChange client script on the variable "u_month" and on the variable "u_year".

If one of the two variables is "None", then the "Date" should be empty.

 

However, I see that a client script runs only on change of one variable.

Can I have the same catalog script for the change of two variables?