yearsAgo produced strange date for individual user.

rlatorre
Kilo Sage

I have a UI Action that produces knowledge articles for the changes related to a release. I use the following to calculate the "valid_to" date on the article record:

gr.valid_to = gs.yearsAgo(-7);

This as work consistently for over a year but a single user has reported and issue. On more than one occasion, the date for this user calculated to "0184-09-01" when it was expected to be "2025-01-16". I have been able to reproduce the issue but not consistently.

Can anyone shed some light on this behavior?

2 ACCEPTED SOLUTIONS

rlatorre
Kilo Sage

It turns out "GlideSystem" Date and Time Functions can cause unexpected behaviour when used for setting fields, as gs.yearsAgo returns a date in a constant format, designed to be used for database queries instead. 

Use the "GlideDateTime", "getDate", and "getDisplayValue" instead.

View solution in original post

Hari haran
Tera Guru

Hariharan_0-1666538413751.png

You can use this Script Include to get the Years ago date.

View solution in original post

3 REPLIES 3

rlatorre
Kilo Sage

Any ideas or does this warrant an incident.


rlatorre
Kilo Sage

It turns out "GlideSystem" Date and Time Functions can cause unexpected behaviour when used for setting fields, as gs.yearsAgo returns a date in a constant format, designed to be used for database queries instead. 

Use the "GlideDateTime", "getDate", and "getDisplayValue" instead.

Hari haran
Tera Guru

Hariharan_0-1666538413751.png

You can use this Script Include to get the Years ago date.