Hi Eric,

There is nothing really wrong with your approach, although there are
other ways to do it as well.  It is up to you if you think the other
ways are better or worse....

For example, you can use the various date-time functions in XQuery for
this:

http://developer.marklogic.com/pubs/4.0/apidocs/DurationDateTimeBuiltins
.html

Something like this:

let $data := <data><date>2008-11-04</date></data>
let $date := xs:date($data/date)
let $mon := fn:month-from-date($date)
let $year := fn:year-from-date($date)
return
fn:concat($mon, " ", $year)

These functions are pretty low-level though, and can be pretty tedious
to use.

Also, there is a nice commons project that does a bunch of stuff with
datetime stuff that might be useful:

http://xqzone.marklogic.com/svn/commons/trunk/dates/

-Danny

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Eric
Palmitesta
Sent: Friday, November 21, 2008 10:03 AM
To: ML Developer Mailing List
Subject: [MarkLogic Dev General] quick dateTime question

Hi all,

Input:
<data>
   <date>2008-11-04</date>
</data>

Output:
"Nov 2008"

I can concatenate the xs:string of the date element with "T00:00:00" to 
create an xs:dateTime type which I can then pass to xdmp:strftime, like 
such:

let $data := <data><date>2008-11-04</date></data>
return
   xdmp:strftime("%b %Y",
     xs:dateTime(concat(string($data/date), "T00:00:00"))
   )

This seems pretty ugly, and the concat is kind of a hack.  Is there a 
more reasonable way to handle this?

Eric
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to