2017-04-17 86 views
0

我如何匹配蜂巢式查詢中的特定日期格式,因爲我必須獲得具有日期格式而不是最大行數的行。蜂巢日期格式匹配

例如,我的最大行有日期格式爲MM/DD/YYYY,我必須列出除上述格式以外的所有行

+----------------------------+--------------------------+--------------------+-----------+ 
| AllocationActBankAccountID | GiftCardActBankAccountID | UpdateTimeStampUtc | Date | 
+----------------------------+--------------------------+--------------------+-----------+ 
|       14 |      14 | 41:39.8   | 4/19/2016 | 
|       14 |      14 | 37:16.4   | 4/20/2016 | 
|       14 |      14 | 52:15.2   | 4/21/2016 | 
|       14 |      14 | 52:15.2   | 2/11/2019 | 
|       14 |      14 | 52:15.2   | 12-Feb-19 |* 
|       14 |      14 | 41:39.8   | 2/13/2019 | 
+----------------------------+--------------------------+--------------------+-----------+ 

我想*標記的數據(日期= 12月 - 19)

+0

你爲什麼使用非ISO格式的字符串,而不是日期/時間戳類型? –

+0

它根據我們正在接受的文件 –

+1

我甚至不能開始描述你在這裏試圖做什麼壞事。這就像整合的概念從來沒有存在過。 –

回答

0
select * 
from mytable 
Where date not rlike '^([1-9]|1[0-2])/([1-9]|[1-2][0-9]|3[0-1])/(19|20)\\d{2}$' 

select * 
from mytable 
Where not 
     (
      date rlike '^\\d{1,2}/\\d{1,2}/\\d{4}$' 
     and cast(split (date,'/')[0] as int) between 1 and 12 
     and cast(split (date,'/')[1] as int) between 1 and 31 
     and cast(split (date,'/')[2] as int) between 1900 and 2099 
     ) 

select date 
from mytable 
Where coalesce(from_unixtime(to_unix_timestamp(date,'M/d/y')),'0000-01-01') 
      not between date '1900-01-01' and date '2099-12-31'