There are a number of bugs that have been fixed on xdmp:parse-dateTime since 
6.0-3.

This works in a recent 8.0 build:

xquery version "1.0-ml";

let $startdateTime:="May 28, 2015"
return
fn:format-dateTime((xdmp:parse-dateTime("[MNn] [D1], [Y0001]",
                xs:string( $startdateTime ) )), "[Y0001]-[M01]-[D01]" )



ð  2015-05-28

-Danny

From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Kari Cowan
Sent: Thursday, May 28, 2015 12:38 PM
To: general@developer.marklogic.com
Subject: [MarkLogic Dev General] XDMP-PATTERNVALUEMISMATCH: xdmp:parse-dateTime

Ok, so my date input below is "May 28, 2015", but my script below says my 
pattern doesn't match. I think it should but according to the comment in 
https://docs.marklogic.com/xdmp:parse-dateTime, as of 6.0-3.1 this function 
does not round-trip non-numeric values. For example 
format-dateTime(current-dateTime(), '[MN]') => JUNE but 
xdmp:parse-dateTime('[MN]', 'JUNE') throws XDMP-PATTERNVALUEMISMATCH.

I need to convert a date like "May 28, 2015" to something like 2015-05-28 so 
that I can use it to compare dates as a part of a query.  What am I missing?  
Here's a scriptlet that illustrates the issue.



xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";;
declare namespace local="this";

declare function local:convert-date($startdateTime as xs:string) as node()*{
                                fn:format-dateTime((xdmp:parse-dateTime("[MNn] 
[D1], [Y0001]",
                                                                  xs:string( 
$startdateTime ) )),
                                                                  
"[Y0001]-[M01]-[D01]" )
};

declare variable $startdateTime as xs:string external;

let $startdateTime:="May 28, 2015"

(:
return $startdateTime
:)

let $this-start-date:= local:convert-date($startdateTime)

  return $this-start-date



________________________________
Learn more about ALM, visit http://www.alm.com . - ALM, an Integrated Media 
Company, is a leading provider of news and information for the legal and 
commercial real estate markets. ALM's market-leading brands include The 
American Lawyer, Corporate Counsel, GlobeSt.com, Insight Conferences, Law.com, 
Law Journal Press, LegalTech, The National Law Journal and Real Estate Forum.
_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to