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 |
+----------------------------+--------------------------+--------------------+-----------+

我想获得 * 标记的数据(日期 = 19 年 2 月 12 日)

4

1 回答 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'
于 2017-04-17T14:23:42.243 回答