如何在 Google AppMaker 中获取两个日期之间的日期范围?
How to get date range between two date in Google AppMaker?
我有两个记录开始日期和结束日期的日期框。我尝试执行以下绑定以获得两个日期之间的日期范围,但它 return 是一个负值
@widget.root.children.DateBox1.value - @widget.root.children.DateBox2.value
以下是我的表单示例
// Binding (option 1 - no datasource)
getValidity(@widget.root.children.StartDate.value, @widget.root.children.EndDate.value);
// Binding (option 2 - with datasource)
getValidity(@datasource.item.StartDate, @datasource.item.EndDate);
// Client script
function getValidity(start, end) {
if (start && end) {
var milliseconds = end - start;
// days: 1000ms * 60s * 60m * 24h
return milliseconds / (1000 * 60 * 60 * 24);
// years: 1000ms * 60s * 60m * 24h * 365d
// return milliseconds / (1000 * 60 * 60 * 24 * 365);
}
return 'n/a';
}
我有两个记录开始日期和结束日期的日期框。我尝试执行以下绑定以获得两个日期之间的日期范围,但它 return 是一个负值
@widget.root.children.DateBox1.value - @widget.root.children.DateBox2.value
以下是我的表单示例
// Binding (option 1 - no datasource)
getValidity(@widget.root.children.StartDate.value, @widget.root.children.EndDate.value);
// Binding (option 2 - with datasource)
getValidity(@datasource.item.StartDate, @datasource.item.EndDate);
// Client script
function getValidity(start, end) {
if (start && end) {
var milliseconds = end - start;
// days: 1000ms * 60s * 60m * 24h
return milliseconds / (1000 * 60 * 60 * 24);
// years: 1000ms * 60s * 60m * 24h * 365d
// return milliseconds / (1000 * 60 * 60 * 24 * 365);
}
return 'n/a';
}