、これが行います。
PARAMETERS
StartDate DateTime,
EndDate DateTime;
SELECT
DateValue(DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])) AS [Date],
Hour(DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])) AS [Hour],
DateDiff("s",
DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate]),
DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10)+1,[StartDate])) AS Duration
FROM
MsysObjects AS Uno,
MsysObjects AS Deca
GROUP BY
DateValue(DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])),
Hour(DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])),
DateDiff("s",
DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate]),
DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10)+1,[StartDate])), DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])
HAVING
DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])<=[EndDate];
編集:
SELECT
DateValue(DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])) AS [Date],
Hour(DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])) AS [Hour],
DateDiff("s",
DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate]),
DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10)+1,[StartDate])) AS Duration
FROM
MsysObjects AS Uno,
MsysObjects AS Deca,
Durations
WHERE
DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])<=[EndDate]
GROUP BY
DateValue(DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])),
Hour(DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])),
DateDiff("s",
DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate]),
DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10)+1,[StartDate]));
へ:あなたが直接あなたのテーブル(デュレーション)を含めることができ
分および分を尊重します:
SELECT
DateValue(DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])) AS [Date],
Hour(DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])) AS [Hour],
DateDiff("s",
IIf(DateDiff("h",[StartDate],DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate]))=0,
[StartDate],
DateValue([StartDate])+TimeSerial(Hour([StartDate])+10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),0,0)),
IIf(DateDiff("h",[EndDate],DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate]))=0,
[EndDate],
DateValue([StartDate])+TimeSerial(Hour([StartDate])+10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10)+1,0,0))) AS Duration
FROM
MsysObjects AS Uno,
MsysObjects AS Deca,
Durations
WHERE
DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])<[EndDate]
GROUP BY
DateValue(DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])),
Hour(DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate])),
DateDiff("s",
IIf(DateDiff("h",[StartDate],DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate]))=0,
[StartDate],
DateValue([StartDate])+TimeSerial(Hour([StartDate])+10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),0,0)),
IIf(DateDiff("h",[EndDate],DateAdd("h",10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10),[StartDate]))=0,
[EndDate],
DateValue([StartDate])+TimeSerial(Hour([StartDate])+10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10)+1,0,0)));
'duration(int、seconds);'カラムの目的は何ですか?それは計算の役割を果たしますか? – Andre
こんにちはAndre、その列を使用する目的はありません。期間フィールドは、end_time - start_time –