I m new to netsuite ,i have to find difference between two dates in netsuite. How can i get the difference of two dates in netsuite through scripts.help me,Thanks.
Custom Field 1.
Label = Date Created
ID: datecreated
Type: Date
Store Value: True
Applies To: Customer
Display > Subtab: Main
Custom Field 2.
Label: Date Closed
ID: dateclosed
Type: Date
Store Value: True
Applies To: Customer
Display > Subtab: Main
Custom Field 3.
Label: Days Open
Type: Date
Store Value: False
Applies To: Customer
Display > Subtab: Main
Validation and Defaulting > Formula: T
Formula field:{dateclosed}-{datecreated}
For example:
Date Created = 9/1/2014
Date Closed = 9/3/2014
The following formula will give you the difference in days. You can add this to the results tab of your saved search.
Formula(Numeric): ROUND({ID of date field}-{ID of other date field})
Note: Either field can be used for the date/time field value.
function date_difference(date1, date2) {
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)); // Get 1 day in milliseconds
return diffDays;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With