пользуйтесь библиотекой QVC
/**
@Function Qvc.DateDiff
@source Qvc_Utility.qvs
Calculates the number of the past interval between the 2 passed dates. For example, if week is requested the function calculates the number of weeks between the 2 passed dates. Supports years, quarters, months, weeks, days, hours, minutes and seconds. Accepts both dates and timestamps for the dates passed.
It is important that the earlier of the passed dates is in param 2 and the later in param 3. This may be improved in the future.
@syntax LET vDateDiff = $(Qvc.DateDiff('DatDiffType', StartDate, EndDate));
@param 1 String. A string defining which mode should be applied to the date diff. Possible values are 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute' and 'second'. Defaults is 'day'.
@param 2 The earlier of the 2 dates to compare.
@param 3 The later of the 2 dates to compare.
*/
SET Qvc.DateDiff = if(lower($1)='year', year($3) - year($2)
,if(lower($1)='quarter', ((year($3)*4) + ceil(month($3)/3)) - ((year($2)*4) + ceil(month($2)/3))
,if(lower($1)='month', ((year($3)*12) + month($3)) - ((year($2)*12) + month($2))
,if(lower($1)='week', floor((($3 - $2)/7))
,if(lower($1)='day', floor($3 - $2)
,if(lower($1)='hour', floor(($3 - $2)*24)
,if(lower($1)='minute', floor(($3 - $2)*1440)
,if(lower($1)='second', floor(($3 - $2)*86400)
, floor($3 - $2) // Default to day
))))))));
/*
@EndFunction*/