我的日期格式为' 12-FEB-2014'我需要将它转换为' yyyy-mm-dd'格式。我试过这个:
xdmp:parse-dateTime("[D01]-[MN,*-3]-[Y0001]","12-FEB-2014")
但它引发了一个例外:
XDMP-PATTERNVALUEMISMATCH: Given value doesn't match with the specified pattern
for parsing dateTime string
答案 0 :(得分:3)
看起来你拥有月份就必须制作自己的变换功能。下面的代码应该给你一个开始。它会影响你给我们的例子。
declare function local:month-name-to-int
( $stringIN as xs:string? ) as xs:string? {
switch (fn:lower-case($stringIN))
case "jan" return "01"
case "feb" return "02"
case "mar" return "03"
case "apr" return "04"
case "may" return "05"
case "jun" return "06"
case "jul" return "07"
case "aug" return "08"
case "sep" return "09"
case "oct" return "10"
case "nov" return "11"
case "dec" return "12"
default return fn:error(xs:QName("ERROR"), "unknown month")
} ;
let $string := "12-FEb-2014"
let $stringTokened := fn:tokenize($string, "-")
return xs:date($stringTokened[3] || "-"||local:month-name-to-int($stringTokened[2]) || "-" || $stringTokened[1])