Hi Ron,
If your timestamp is available in IETF format, you can use fn:parse-ietf-date [1]. Otherwise, you’ll need to write a simple function by yourself:
declare variable $MONTHS := ( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
declare function local:to-date($string) { let $m := index-of($MONTHS, substring-before($string, ' ')) let $y := xs:integer(substring-after($string, ' ')) return xs:date(string-join(( format-number($y, '0000'), format-number($m, '00'), '01' ), '-')) }; local:to-date('March 2017')
Best, Christian
[1] https://www.w3.org/TR/xpath-functions-31/#func-parse-ietf-date
On Fri, Nov 2, 2018 at 9:09 PM Ron Katriel rkatriel@mdsol.com wrote:
Hi,
Is there a BaseX function for converting a string date in the form of “March 2017” to xs:date or xs:dateTime?
Thanks, Ron