- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2021 07:07 AM
Hi Team,
How to select only year from date field.
please any one help on this.
Regards,
Pushpa
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2021 07:52 AM
Hi,
for that you can use onLoad client script with GlideAjax
1) script include will check which is the current quarter and based on that hide the other quarter
Sample script to determine the quarter in server side
var test = new GlideDateTime();
var month = test.getMonth();
var quarter = Math.ceil(month/3);
gs.info('Current quarter is->'+quarter);
Output:
[0:00:00.069] Script completed in scope global: script
Script execution history and recovery available here
*** Script: Current quarter is->2
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2021 07:19 AM
Hi Pushpa
I think for this you will have to create custom fields with drop down values for year 2019,2020, 2021.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2021 07:20 AM
Hello
Then this is not possible; Date field always store date in YYYY-mm-DD format.
You can not make change in servicenow OOB variables.
Please Mark Correct and Helpful
Thanks and Regards
Gaurav Shirsat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2021 07:21 AM
Well there are multiple ways to achieve this it depends on the requirement and what form you are working on, below are the items that can help you:
If you're working on catalogue item you can create your macro that shows only the year field as years YYYY
If you are working on a form level below options help you:
1. Create a string field make it to accept only integer (isNaN) and limit the field to four digits.
2. Create a choice list and use background script to populate the choices for one time.
3. If your working on date field then you have to to use regex to validate the date field to trim the month & date i.e. DD/MM/
Please let me know where exactly your requirement is so I shall help you further. Kindly mark the answer helpful if helped.
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2021 07:41 AM
Hi,
if current year is 2021 and current month is september, then Q3& Q4 shouble be visible.
