[英]How to get difference between two dates in netsuite?
I m new to netsuite ,i have to find difference between two dates in netsuite. 我是netsuite的新手,我必须找到netsuite中两个日期之间的区别。 How can i get the difference of two dates in netsuite through scripts.help me,Thanks. 如何通过脚本获取netsuite中两个日期的区别。帮助我,谢谢。
Custom Field 1. 自定义字段1。
Label = Date Created 标签=创建日期
ID: datecreated ID:datecreated
Type: Date 类型:日期
Store Value: True 商店价值:真实
Applies To: Customer 适用于:客户
Display > Subtab: Main 显示>子选项卡:主要
Custom Field 2. 自定义字段2。
Label: Date Closed 标签:关闭日期
ID: dateclosed ID:dateclosed
Type: Date 类型:日期
Store Value: True 商店价值:真实
Applies To: Customer 适用于:客户
Display > Subtab: Main 显示>子选项卡:主要
Custom Field 3. 自定义字段3。
Label: Days Open 标签:天开放
Type: Date 类型:日期
Store Value: False 商店价值:错误
Applies To: Customer 适用于:客户
Display > Subtab: Main 显示>子选项卡:主要
Validation and Defaulting > Formula: T 验证和默认>公式:T
Formula field:{dateclosed}-{datecreated}
公式字段:{dateclosed}-{datecreated}
For example: 例如:
Date Created = 9/1/2014 创建日期= 9/1/2014
Date Closed = 9/3/2014 截止日期= 2014年9月3日
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;
}
You can convert a Text date ('01/01/2014') to a Date object with nlapiStringtoDate. 您可以使用nlapiStringtoDate将文本日期('01 / 01/2014')转换为Date对象。
So basically you go 所以基本上你去吧
timeDiff = Math.abs(nlapiStringtoDate(myDate).getTime() - (new Date).getTime()) diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.