2 things here: - your timestamp is not regular Unix time, it seems to count milliseconds rather than seconds since the epoch
- it seems you need to xs:dayTimeDuration instead of xs:duration (not sure why, I think we introduced xs:duration in XQuery 3.0, but MarkLogic does not complain about it per se, just the value it holds) The following seems to do what you want (given the assumptions above): let $seconds := 1458797764507 return xs:dateTime('1970-01-01T00:00:00+00:00') + xs:dayTimeDuration('PT' || ($seconds div 1000) || 'S') Regards, -- Florent Georges http://fgeorges.org/ http://h2oconsulting.be/ On 23 September 2016 at 11:23, Debin, Infant Jerald (LNG-CON) wrote: > Hi, > > > > When I use the below command it is throwing error > > > > xs:dateTime('1970-01-01T00:00:00+00:00') + xs:duration('PT' || > "1458797764507" || 'S') > > > > Error: > > > > [1.0-ml] XDMP-EXPR: (err:XPTY0004) xs:dateTime("1970-01-01T00:00:00Z") + > xs:duration("P16884233DT9H15M7S") -- Invalid expression > > > > Stack trace: > > > > at 1:41: > > 1: xs:dateTime('1970-01-01T00:00:00+00:00') + xs:duration('PT' || > "1458797764507" || 'S') > > > > -----Original Message----- > From: general-boun...@developer.marklogic.com > [mailto:general-boun...@developer.marklogic.com] On Behalf Of Florent > Georges > Sent: Friday, September 23, 2016 3:26 AM > To: MarkLogic Developer Discussion > Subject: Re: [MarkLogic Dev General] Convert unix timestamp to HH/MM/SS in > marklogic > > > > Hi, > > > > You should be able to use the following expression, given $seconds is your > timestamp, to get a date-time. I am not sure about the limits on the number > of seconds you can have in a duration, though: > > > > xs:dateTime('1970-01-01T00:00:00+00:00') > > + xs:duration('PT' || $seconds || 'S') > > > > Regards, > > > > -- > > Florent Georges > > http://fgeorges.org/ > > http://h2oconsulting.be/ > > > > > > On 23 September 2016 at 09:14, Debin, Infant Jerald (LNG-CON) wrote: > >> Hi, > >> > >> > >> > >> Is there a way to convert the unix timestamp to HH/MM/SS format in >> marklogic > >> using xquery. > >> > >> > >> > >> Unit timestamp that is in xml is in below , > >> > >> > >> > >> <timestamp>1472812470453</timestamp> > >> > >> > >> > >> Thanks, > >> > >> Debin > >> > >> > >> _______________________________________________ > >> General mailing list > >> General@developer.marklogic.com > >> Manage your subscription at: > >> http://developer.marklogic.com/mailman/listinfo/general > >> > > _______________________________________________ > > General mailing list > > General@developer.marklogic.com > > Manage your subscription at: > > http://developer.marklogic.com/mailman/listinfo/general > > > _______________________________________________ > General mailing list > General@developer.marklogic.com > Manage your subscription at: > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general