Create a date table between 2 dates

前端 未结 1 1170
我在风中等你
我在风中等你 2020-12-12 06:20

I am a newbie in programming and trying to add some automation in my team to help with daily operation.

I try to create a function to create interest payment schedu

相关标签:
1条回答
  • 2020-12-12 07:05

    You can use the MSysObjects table and a Cartesian query to create this:

    PARAMETERS 
        Period Text ( 255 ), 
        Periods Short, 
        FirstDate DateTime;
    SELECT DISTINCT 
        10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10)+1 As Sequence,
        DateAdd([Period],[Sequence]-1,[FirstDate]) AS [DateStart],
        DateAdd([Period],[Sequence],[FirstDate]) AS [DateEnd]
    FROM 
        MSysObjects AS Uno, 
        MSysObjects AS Deca
    WHERE 
        10*Abs([Deca].[id] Mod 10)+Abs([Uno].[id] Mod 10)<[Periods]
    

    Run this with the parameters:

    Period: q
    Periods: 4
    FirstDate: 2017-04-14
    

    0 讨论(0)
提交回复
热议问题