Set Calendar duration / default time problem?

davidpanson
Mega Expert

Hi everyone,

I've trying to calculate the duration of tasks. I've got a simple business rule that does in fact update the duration but I noticed something that I would like some help understanding. even though it updates the field correctly with the value I've expected... when I try to call the field in a info message

it displays a different value. The mysterious 1970 default. So why is this value here? Where does it come from? Is my duration not actually set? I thought business rules actually changed the data not just your form view. Am I doing something wrong?

I've posted my code below.

snip.PNG

code.PNG

I've seen lots of forums about 1970s popping up when people try and and work with dates but not too many great explanations. I've gathered that it's probably an issue with trying to display a string thinking it's a date/time or something like that but obviously if I was sure I wouldn't be asking.

Thanks!

1 ACCEPTED SOLUTION

LaurentChicoine
Tera Guru

Hi David,



The duration is stored in a DateTime field, which mean it is stored as a number of seconds since 1970-01-01 and when asking for the value it is returning a date.



What you can do to display this in a message with the right format is to use the displayValue, for example:



gs.addInfoMessage(current.business_duration.getDisplayValue())


View solution in original post

2 REPLIES 2

LaurentChicoine
Tera Guru

Hi David,



The duration is stored in a DateTime field, which mean it is stored as a number of seconds since 1970-01-01 and when asking for the value it is returning a date.



What you can do to display this in a message with the right format is to use the displayValue, for example:



gs.addInfoMessage(current.business_duration.getDisplayValue())


Well now I feel silly. I've been using .getDisplayValue() in all my testing scripts but forgot to add it here. Although I'm still glad I asked because I did not realize that duration was actually stored as seconds since 1970-01-01 and that is a good bit of information. Thank you for the response.