On record producer form i have start field i want to change the date format

nikhitha24
Tera Guru

Hi Everyone,

 

Can someone please help me on the below query,

 

On record producer form i have start field i want to change the date format YYYY/MM/DD it should change to DD/MM/YYYY for specific record producer field (start date)  it should not effect system level.

Please help me to achieve this.

Thank you..

 

 

2 REPLIES 2

PritamG
Mega Guru

you can achieve this using a client script (onLoad or onChange) in the record producer form.

client script (type: onLoad or onChange, variable: start date)

function onLoad() {
    var startDate = g_form.getValue('start_date'); 
    if (startDate) {
        var parts = startDate.split('-'); 
        var formattedDate = parts[2] + '/' + parts[1] + '/' + parts[0]; 
        g_form.setValue('start_date', formattedDate);
    }
}

Key Points:

 changes date format only for the specific record producer field
 does not impact system-wide settings
 ensures date is displayed as DD/MM/YYYY in the UI

 

Mark Manders
Mega Patron

You can check on the below community post, but be real careful with this. By default it will take the date format from the user and it can easily be set incorrectly. A user with MM/DD/YYYY as format will write February 6th as 02/06/2025 while the system will set June 2nd because of your manipulation. 

 

What is the business case behind this? Especially if it's just for one record producer. If it is because of later handling through integration or anything like that, it is better handled there. The format used by the user is translated to the system format. Changing it where you need that other format may be a better solution than creating confusion on a user level (users will make mistakes)

 

https://www.servicenow.com/community/now-platform-forum/how-to-set-date-variable-in-mm-dd-yyyy-forma...

 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark