Date format changes after exporting

Vikram3
Giga Guru

Hi all,

I have a field type as duration. Field name is "Subscription"

find_real_file.png

After exporting to excel I'm getting as in milliseconds I hope so.

find_real_file.png

After transformation again Subscription field values is not updating as it remains empty.

Kindly help. Thanks in advance.

1 ACCEPTED SOLUTION

AirSquire
Tera Guru

Hi Vikram,

This link might be helpful to you:

https://community.servicenow.com/community?id=community_question&sys_id=0f634b25dbd8dbc01dcaf3231f96198b

 

Regards

Dhruv

View solution in original post

2 REPLIES 2

AirSquire
Tera Guru

Hi Vikram,

This link might be helpful to you:

https://community.servicenow.com/community?id=community_question&sys_id=0f634b25dbd8dbc01dcaf3231f96198b

 

Regards

Dhruv

mukulgupta
ServiceNow Employee
ServiceNow Employee

Hi Vikram,

 

If this something which you doing the exports only for the reporting purpose that then converting/exporting to PDF works perfectly fine.

If you are looking for excel specifically, then you may need a string field to hold this date data and then export it to excel. That way time conversation doesn't happen and it keeps the original duration intact.

 

You can do a workaround like introducing a new field

> The field will calculate the seconds to hours, minutes, seconds through javascript

> You can calculate either by using calculate field in the sys_dictionary OR

> You can write a before BR which triggers everytime actual effort to date changes and calculates and puts inside -

For example, the timestamp of current time returns in milliseconds (in your case the actual effort to date in seconds)

 

var totalSec = new Date().getTime() / 1000;
var hours = parseInt( totalSec / 3600 ) % 24;
var minutes = parseInt( totalSec / 60 ) % 60;
var seconds = totalSec % 60;

var result = (hours < 10 ? "0" + hours : hours) + "-" + (minutes < 10 ? "0" + minutes : minutes) + "-" + (seconds   < 10 ? "0" + seconds : seconds);

 

Please let us know if the shared info was helpful by marking the response as Helpful.

Feel free to reach out if you have any additional questions.

Best Regards,

Mukul Gupta @ ServiceNow