Hi Kari,
I also see the different behavior on 7 and the latest 8. There is a bug fix in
my code not yet released, which is likely why it is working for me on the
latest 8.
The problem is with the Month names. There is a note in the documentation
saying this does not always parse the month names.
The only workaround I can think of is to substitute in the month number for the
month name, as that seems to work on 7.0-5. But that might get you past the
problem.
For example, this works on 7.0-5.1:
let $startdateTime := "05 28 2015"
return
xdmp:parse-dateTime("[M1] [D1] [Y0001]", $startdateTime, "en")
=>
2015-05-28T00:00:00-07:00
-Danny
From: [email protected]
[mailto:[email protected]] On Behalf Of Kari Cowan
Sent: Thursday, May 28, 2015 2:24 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] XDMP-PATTERNVALUEMISMATCH:
xdmp:parse-dateTime
Hmm, I have 8.02 on my local machine, and it still throws that error so it must
be more recent than that version. Either way, we're using v.7 in my dev/stage
environments (where I am seeing an error), and v.6 on production. It may be a
while I have 8 available to me on our live servers.
Any other workaround you might suggest?
From: [email protected]
[mailto:[email protected]] On Behalf Of Danny Sokolsky
Sent: Thursday, May 28, 2015 1:50 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] XDMP-PATTERNVALUEMISMATCH:
xdmp:parse-dateTime
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:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Kari Cowan
Sent: Thursday, May 28, 2015 12:38 PM
To: [email protected]<mailto:[email protected]>
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.
________________________________
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
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general