我有一個帶有5個記錄的字段sourcefilename的表。以下是記錄。檢查字符串是否有效
SN. SOURCEFILENAME
1. 20170215095453_1.Iredell Memorial Hospital Dental Eligibility.xls_INFREPT01.txt
2. Iredell Memorial Hospital Eligibility April 2017.xls_INFREPT01.txt
3. Iredell Memorial Hospital Eligibility March 2017.xls_INFREPT01.txt
4. Iredell Memorial Hospital Eligibility May 2017.xls_INFREPT01.txt
5. Iredell Memorial Hospital October 2016 Dental Eligibility.xls_EligData.txt
我只需要提取前8個字符,並檢查它是否有效的日期。如果是有效日期,則返回TRUE else FALSE。
我試過了ISDATE函數。還有其他的選擇嗎?
SELECT DISTINCT SubStr(sourcefilename,1,8),
CASE WHEN isdate(SubStr(sourcefilename,1,8),'YYYYMMDD') = 1 THEN 'TRUE' ELSE 'FALSE' END FROM ai_4451_1_metl;
@ user7294900:如果使用TO_DATE。比較什麼價值? SELECT DISTINCT SubStr(sourcefilename,1,8), CASE WHEN to_Date(SubStr(sourcefilename,1,8),'YYYYMMDD')= ???????? THEN'TRUE' ELSE'FALSE'END FROM ai_4451_1_metl; –