久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <legend id='jqhDQ'><style id='jqhDQ'><dir id='jqhDQ'><q id='jqhDQ'></q></dir></style></legend>

    <small id='jqhDQ'></small><noframes id='jqhDQ'>

    <i id='jqhDQ'><tr id='jqhDQ'><dt id='jqhDQ'><q id='jqhDQ'><span id='jqhDQ'><b id='jqhDQ'><form id='jqhDQ'><ins id='jqhDQ'></ins><ul id='jqhDQ'></ul><sub id='jqhDQ'></sub></form><legend id='jqhDQ'></legend><bdo id='jqhDQ'><pre id='jqhDQ'><center id='jqhDQ'></center></pre></bdo></b><th id='jqhDQ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='jqhDQ'><tfoot id='jqhDQ'></tfoot><dl id='jqhDQ'><fieldset id='jqhDQ'></fieldset></dl></div>
    • <bdo id='jqhDQ'></bdo><ul id='jqhDQ'></ul>

      <tfoot id='jqhDQ'></tfoot>

      獲取兩個日期之間的日期列表

      Get a list of dates between two dates(獲取兩個日期之間的日期列表)

          <bdo id='fyjEh'></bdo><ul id='fyjEh'></ul>
          <i id='fyjEh'><tr id='fyjEh'><dt id='fyjEh'><q id='fyjEh'><span id='fyjEh'><b id='fyjEh'><form id='fyjEh'><ins id='fyjEh'></ins><ul id='fyjEh'></ul><sub id='fyjEh'></sub></form><legend id='fyjEh'></legend><bdo id='fyjEh'><pre id='fyjEh'><center id='fyjEh'></center></pre></bdo></b><th id='fyjEh'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='fyjEh'><tfoot id='fyjEh'></tfoot><dl id='fyjEh'><fieldset id='fyjEh'></fieldset></dl></div>
            <tbody id='fyjEh'></tbody>
          <tfoot id='fyjEh'></tfoot>
            • <small id='fyjEh'></small><noframes id='fyjEh'>

              1. <legend id='fyjEh'><style id='fyjEh'><dir id='fyjEh'><q id='fyjEh'></q></dir></style></legend>
              2. 本文介紹了獲取兩個日期之間的日期列表的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                使用標準的 mysql 函數可以編寫一個查詢,該查詢將返回兩個日期之間的天數列表.

                Using standard mysql functions is there a way to write a query that will return a list of days between two dates.

                例如,給定 2009-01-01 和 2009-01-13,它將返回一個帶有值的單列表:

                eg given 2009-01-01 and 2009-01-13 it would return a one column table with the values:

                 2009-01-01 
                 2009-01-02 
                 2009-01-03
                 2009-01-04 
                 2009-01-05
                 2009-01-06
                 2009-01-07
                 2009-01-08 
                 2009-01-09
                 2009-01-10
                 2009-01-11
                 2009-01-12
                 2009-01-13
                

                看來我還不清楚.我想生成這個列表.我將值存儲在數據庫中(按日期時間),但希望它們在左外部連接上聚合到上述日期列表(我希望從某些連接的右側獲得空值幾天,并將處理此問題).

                It appears I have not been clear. I want to GENERATE this list. I have values stored in the database (by datetime) but want them to be aggregated on a left outer join to a list of dates as above (I am expecting null from the right side of some of this join for some days and will handle this).

                推薦答案

                我會使用這個存儲過程將您需要的間隔生成到名為 time_intervals 的臨時表中,然后加入并聚合您的數據表使用臨時 time_intervals 表.

                I would use this stored procedure to generate the intervals you need into the temp table named time_intervals, then JOIN and aggregate your data table with the temp time_intervals table.

                該過程可以生成您在其中指定的所有不同類型的間隔:

                The procedure can generate intervals of all the different types you see specified in it:

                call make_intervals('2009-01-01 00:00:00','2009-01-10 00:00:00',1,'DAY')
                .
                select * from time_intervals  
                .
                interval_start      interval_end        
                ------------------- ------------------- 
                2009-01-01 00:00:00 2009-01-01 23:59:59 
                2009-01-02 00:00:00 2009-01-02 23:59:59 
                2009-01-03 00:00:00 2009-01-03 23:59:59 
                2009-01-04 00:00:00 2009-01-04 23:59:59 
                2009-01-05 00:00:00 2009-01-05 23:59:59 
                2009-01-06 00:00:00 2009-01-06 23:59:59 
                2009-01-07 00:00:00 2009-01-07 23:59:59 
                2009-01-08 00:00:00 2009-01-08 23:59:59 
                2009-01-09 00:00:00 2009-01-09 23:59:59 
                .
                call make_intervals('2009-01-01 00:00:00','2009-01-01 02:00:00',10,'MINUTE')
                . 
                select * from time_intervals
                .  
                interval_start      interval_end        
                ------------------- ------------------- 
                2009-01-01 00:00:00 2009-01-01 00:09:59 
                2009-01-01 00:10:00 2009-01-01 00:19:59 
                2009-01-01 00:20:00 2009-01-01 00:29:59 
                2009-01-01 00:30:00 2009-01-01 00:39:59 
                2009-01-01 00:40:00 2009-01-01 00:49:59 
                2009-01-01 00:50:00 2009-01-01 00:59:59 
                2009-01-01 01:00:00 2009-01-01 01:09:59 
                2009-01-01 01:10:00 2009-01-01 01:19:59 
                2009-01-01 01:20:00 2009-01-01 01:29:59 
                2009-01-01 01:30:00 2009-01-01 01:39:59 
                2009-01-01 01:40:00 2009-01-01 01:49:59 
                2009-01-01 01:50:00 2009-01-01 01:59:59 
                .
                I specified an interval_start and interval_end so you can aggregate the 
                data timestamps with a "between interval_start and interval_end" type of JOIN.
                .
                Code for the proc:
                .
                -- drop procedure make_intervals
                .
                CREATE PROCEDURE make_intervals(startdate timestamp, enddate timestamp, intval integer, unitval varchar(10))
                BEGIN
                -- *************************************************************************
                -- Procedure: make_intervals()
                --    Author: Ron Savage
                --      Date: 02/03/2009
                --
                -- Description:
                -- This procedure creates a temporary table named time_intervals with the
                -- interval_start and interval_end fields specifed from the startdate and
                -- enddate arguments, at intervals of intval (unitval) size.
                -- *************************************************************************
                   declare thisDate timestamp;
                   declare nextDate timestamp;
                   set thisDate = startdate;
                
                   -- *************************************************************************
                   -- Drop / create the temp table
                   -- *************************************************************************
                   drop temporary table if exists time_intervals;
                   create temporary table if not exists time_intervals
                      (
                      interval_start timestamp,
                      interval_end timestamp
                      );
                
                   -- *************************************************************************
                   -- Loop through the startdate adding each intval interval until enddate
                   -- *************************************************************************
                   repeat
                      select
                         case unitval
                            when 'MICROSECOND' then timestampadd(MICROSECOND, intval, thisDate)
                            when 'SECOND'      then timestampadd(SECOND, intval, thisDate)
                            when 'MINUTE'      then timestampadd(MINUTE, intval, thisDate)
                            when 'HOUR'        then timestampadd(HOUR, intval, thisDate)
                            when 'DAY'         then timestampadd(DAY, intval, thisDate)
                            when 'WEEK'        then timestampadd(WEEK, intval, thisDate)
                            when 'MONTH'       then timestampadd(MONTH, intval, thisDate)
                            when 'QUARTER'     then timestampadd(QUARTER, intval, thisDate)
                            when 'YEAR'        then timestampadd(YEAR, intval, thisDate)
                         end into nextDate;
                
                      insert into time_intervals select thisDate, timestampadd(MICROSECOND, -1, nextDate);
                      set thisDate = nextDate;
                   until thisDate >= enddate
                   end repeat;
                
                 END;
                

                這篇文章,我在那里為 SQL Server 構建了一個類似的函數.

                Similar example data scenario at the bottom of this post, where I built a similar function for SQL Server.

                這篇關于獲取兩個日期之間的日期列表的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數根據 N 個先前值來決定接下來的 N 個行)
                reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達式的結果;條款?)
                Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數的 ignore 選項是忽略整個事務還是只是有問題的行?) - IT屋-程序員軟件開發技
                Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時出錯,使用 for 循環數組)
                pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調用 o23.load 時發生錯誤 沒有合適的驅動程序)
                How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數據庫表作為 Spark 數據幀讀取?)

                    <bdo id='r3orP'></bdo><ul id='r3orP'></ul>
                      <tbody id='r3orP'></tbody>
                    <legend id='r3orP'><style id='r3orP'><dir id='r3orP'><q id='r3orP'></q></dir></style></legend>

                    <small id='r3orP'></small><noframes id='r3orP'>

                    • <i id='r3orP'><tr id='r3orP'><dt id='r3orP'><q id='r3orP'><span id='r3orP'><b id='r3orP'><form id='r3orP'><ins id='r3orP'></ins><ul id='r3orP'></ul><sub id='r3orP'></sub></form><legend id='r3orP'></legend><bdo id='r3orP'><pre id='r3orP'><center id='r3orP'></center></pre></bdo></b><th id='r3orP'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='r3orP'><tfoot id='r3orP'></tfoot><dl id='r3orP'><fieldset id='r3orP'></fieldset></dl></div>
                      <tfoot id='r3orP'></tfoot>
                          主站蜘蛛池模板: 国产激情在线播放 | 欧美日产国产成人免费图片 | 日本视频中文字幕 | 亚洲一区二区视频 | 91tv在线观看 | 中文字幕视频一区 | 天天操综合网站 | 国产剧情一区 | 激情av免费看| 国产精品色av | 毛片在线免费播放 | 二区国产| 精品欧美乱码久久久久久1区2区 | 国产精品亚洲一区 | 久久久女女女女999久久 | www国产亚洲精品久久网站 | 一区二区免费高清视频 | 欧美日韩亚洲国产 | 成人在线 | 最新一级毛片 | 性色av一区二区三区 | 激情婷婷| 91精品国产综合久久精品 | 国产xxxx搡xxxxx搡麻豆 | 久日精品 | 亚洲精品在线视频 | 一区二区日韩 | 欧美mv日韩mv国产网站91进入 | 欧美一级片在线观看 | 日韩另类 | 日本午夜精品一区二区三区 | www.jizzjizz| 嫩草国产 | 免费的av| av网站免费在线观看 | 亚洲免费人成在线视频观看 | 欧美成人激情 | 色婷婷狠狠 | 国产一级毛片精品完整视频版 | 色毛片| 男女网站免费观看 |