隨筆 - 225  文章 - 98  trackbacks - 0
          <2012年9月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456

          隨筆分類

          相冊

          報表工具廠商們

          搜索

          •  

          最新評論

          閱讀排行榜


          在如今各式各樣的數(shù)據(jù)庫中,對時間類型的數(shù)據(jù)處理也不盡相同。要將FineReport中的時間類型數(shù)據(jù)與數(shù)據(jù)庫中的時間類型數(shù)據(jù)對接,必須借助一些格式轉(zhuǎn)換函數(shù)。

          在此,以常用的數(shù)據(jù)庫OracleSQL Server為例,舉例講述其與FineReport之間時間類型的轉(zhuǎn)換,同F(xiàn)R使用者們共同交流。

          Oracle and FineReport

          例如:

          Oracle數(shù)據(jù)庫中有名為example的數(shù)據(jù)表,表中有名為Date的時間字段FineReport中有一個時間參數(shù)a現(xiàn)要求選出example表中Date字段與參數(shù)a相等的記錄。

          分情況轉(zhuǎn)換方法如下表所示

          Oracle

          FineReport

          SQL語法

          日期類型字段

          Date(yyyy-MM-dd)

          時間類型參數(shù)a /字符串類型參數(shù)a

          Select * from example 

          where Date=to_date('${a}','yyyy-MM-dd')

          字符串類型字段

          Date(MM/dd/yyyy)

          時間類型參數(shù)a /字符串類型參數(shù)a

          Select * from example 

          where Date=to_char('${a}','MM/dd/yyyy')

          時間類型字段

          Date(yyyy MM dd hh24:mi:ss) /

          (yyyy MM dd hh12:mi:ss)

          時間類型參數(shù)a /字符串類型參數(shù)a

          Select * from example 

          where Date=to_char('${a}','yyyy MM dd hh24:mi:ss') 

          Select * from example 

          where Date=to_char('${a}','yyyy MM dd hh12:mi:ss')

          字符串類型字段

          Date(yyyy.MM.dd hh24:mi:ss) /

          (yyyy.MM.dd hh12:mi:ss)

          時間類型參數(shù)a /字符串類型參數(shù)a

          Select * from example 

          where Date=to_char('${a}','yyyy.MM.dd hh24:mi:ss') /

          Select * from example 

          where Date=to_char('${a}','yyyy.MM.dd hh12:mi:ss')

           

          SQL Server and FineReport

          例如:

          Oracle數(shù)據(jù)庫中有名為example的數(shù)據(jù)表,表中有名為Date的時間字段FineReport中有一個時間參數(shù)a現(xiàn)要求選出example表中Date字段與參數(shù)a相等的記錄。SQL Server中對不同的時間格式都有對應(yīng)的不同公式寫法)

          日期參數(shù)對應(yīng)關(guān)系如下表所示:

          SQL Server

          FineReport

          SQL語法

          Date

          (mon dd yyyy hh:miAM/ PM)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 0) /

          Select * from example 

          where Date= CONVERT(varchar(100), ${a}, 100)

          Date(mm/dd/yy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 1)

          Date(yy.mm.dd)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 2)

          Date(dd/mm/yy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 3)

          Date(dd.mm.yy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 4)

          Date(dd-mm-yy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 5)

          Date(dd mon yy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 6)

          Date(mon dd, yy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 7)

          Date(hh:mm:ss)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 8) 

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 108)

          Date

          (mon dd yyyy hh:mi:ss:mmmAM/ PM)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 9) 

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 109)

          Date(mm-dd-yy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 10)

          Date(yy/mm/dd)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 11)

          Date(yymmdd)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 12)

          Date

          (dd mon yyyy hh:mm:ss:mmm(24h))

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 13) 

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 113)

          Date(hh:mi:ss:mmm(24h))

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 14) 

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 114)

          Date

          (yyyy-mm-dd hh:mm:ss[.fff])

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 20) 

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 120)

          Date

          (yyyy-mm-dd hh:mm:ss[.fff])

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 21) 

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 121)

          Date(mm/dd/yyyy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 101)

          Date(yyyy.mm.dd)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 102)

          Date(dd/mm/yyyy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 103)

          Date(dd.mm.yyyy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 104)

          Date(dd-mm-yyyy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 105)

          Date(dd mon yyyy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 106)

          Date(Mon dd, yyyy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 107)

          Date(mm-dd-yyyy)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 110)

          Date(yyyy/mm/dd)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 111)

          Date(yyyymmdd)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 112)

          Date

          (yyyy-mm-ddThh:mi:ss.mmm (no spaces))

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 126)

          Date

          (yyyy-mm-ddThh:mi:ss.mmmZ (no spaces))

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 127)

          Date

          (dd mon yyyy hh:mi:ss:mmmAM)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 130)

          Date

          (dd/mm/yy hh:mi:ss:mmmAM)

          時間類型參數(shù)a /

          字符串類型參數(shù)a

          Select * from example 

          where Date=CONVERT(varchar(100), ${a}, 131)



          了解Java報表工具就從這里開始
          posted on 2012-09-06 23:45 season 閱讀(862) 評論(0)  編輯  收藏 所屬分類: Java報表—技術(shù)知識
          主站蜘蛛池模板: 马公市| 清流县| 霍林郭勒市| 永善县| 社旗县| 大方县| 左云县| 那曲县| 河东区| 朝阳市| 台南县| 怀来县| 会理县| 兴仁县| 伊吾县| 盐池县| 沈阳市| 专栏| 忻城县| 株洲市| 甘孜县| 新安县| 海盐县| 彩票| 神农架林区| 兴文县| 蚌埠市| 姚安县| 桑植县| 镇宁| 临沭县| 石泉县| 青州市| 堆龙德庆县| 临沂市| 仁寿县| 麻栗坡县| 页游| 卢湾区| 永修县| 霞浦县|