How to modify date field to pick only month and year

Asif_Jawed
Tera Expert

I have a field of type 'date' in catalog item and i want to pick only month and year.  Currently the pop up window is showing date, month and year but i want only only and year to pop up and after selecting it. The month and year should display in the field. example: July, 2023 or June - 2022. 

Screenshot 2023-07-07 111000.jpg

 

2 ACCEPTED SOLUTIONS

Samaksh Wani
Giga Sage
Giga Sage

Hi Asif,

 

Create a two field of dropdown, One for Month and One for year, But for Storing purpose you can concatenate both values like this:-  July 2023

 

Because in the out of the box calendar, date picker will always be present.

 

Plz Mark my Solution as Accept and give me thumbs up.if you find it helpful

 

Regards,

Samaksh

View solution in original post

@Asif_Jawed 

to ensure year is dynamic you can add as of now 10 years such as 2022 to 2032 in the choices

Ensure you create a scheduled job which runs every 5-10 years which adds new choices to that choice variable such as when job runs in 2028 then it will add new choices from 2028 onwards etc

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

View solution in original post

7 REPLIES 7

Samaksh Wani
Giga Sage
Giga Sage

Hi Asif,

 

Create a two field of dropdown, One for Month and One for year, But for Storing purpose you can concatenate both values like this:-  July 2023

 

Because in the out of the box calendar, date picker will always be present.

 

Plz Mark my Solution as Accept and give me thumbs up.if you find it helpful

 

Regards,

Samaksh

Ankur Bawiskar
Tera Patron
Tera Patron

@Asif_Jawed 

Please check response shared by @Samaksh Wani 

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

Asif_Jawed
Tera Expert

Hi @Samaksh Wani ,

Thank you for replying so fast.
How to concatinate both values and moreover if I create two dropdown then the year dropdown should have all the year dynamically.

 

Hello Asif,

 

In that case plz use normal date picker and select date as 1 only but for storing purpose, you can trim or make substring of only month and year.

 

You need to write a script for that using Javascript functions.

 

Plz Mark my Solution as Accept and give me thumbs up.if you find it helpful

 

Regards,

Samaksh.