Hi Mark,

Could you try this. Hope this should replace your date value.

declare namespace xh="http://newnamespace/";;
for $t in (/xh:TABLE)/xh:CURRENTDATE
let $tt := $t/string
let $parts := fn:tokenize($t, " ")
let $datepart := fn:tokenize($parts[1], "/")
let $timestamp := fn:concat($datepart[3],"-",
$datepart[1],"-",$datepart[2],"T",$parts[2])
return xdmp:node-replace($t/text(), text{$timestamp} )

Thank you!
Indrajeet

On Wed, Apr 22, 2015 at 2:07 AM, Mark Shanks <[email protected]>
wrote:

> Hi,
>
> I have some data ingested into Marklogic, but found that marklogic cannot
> interpret dates in the form sql typically outputs, e.g., 03/17/2014
> 09:55:22. Instead, it should be in the xml form 2014-04-30T05:30:41. I
> wrote the following xquery to convert all of the dates in the referenced
> column, but it puts the entry in as a node but marklogic doesn't recognize
> it as a node. What is going wrong?
>
> declare namespace xh="http://newnamespace/";;
> for $t in (/xh:TABLE)/xh:CURRENTDATE
> let $tt := $t/string
> let $parts := fn:tokenize($t, " ")
> let $datepart := fn:tokenize($parts[1], "/")
> let $timestamp := fn:concat($datepart[3],"-",
> $datepart[1],"-",$datepart[2],"T",$parts[2])
> return xdmp:node-replace($t,
> text{fn:concat("<CURRENTDATE>",$timestamp,"</CURRENTDATE>")} )
>
> Note that I tried the element statement in the node-replace, but this
> would rewrite the node with an empty namespace. It wasn't clear to me how
> to reference the correct namespace. Is there also a general function to
> convert all dates in marklogic into xml format?
>
> Thanks.
>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to