> > at [1] I read about the afn:now() function. I want to use it, to add a 
> > column
> to my query results, which shows the current time.
> >
> > Is it possible to adjust the output format of afn:now()? Currently,
> > the format looks like this: 2015-10-14T11:50:34.583+02:00
> >
> > Could this be changed to, for instance, the following format:
> > 2015-10-14T11:50+02:00
> 
> You can manipulate the value or manipulate the lexical form.
> 
> There are functions to access the date/time components of the VALUE.
> Arthimetic on xsd:dateTimes is supported using xsd:durations (and it's
> derived types).
> 
> 
> Or you can hack the lexical form.  It so happens that '.' only occurs in
> the fractional part of to seconds and not before.
> 
> # Assumes there is a factional part. There is for afn:now.
> STRBEFORE(STR(afn:now()),'.')
> 
> or use REPLACE.
> # General
> REPLACE(STR(afn:now()), '(\\.\\d*)?(Z|\\+\\d\\d:\\d\\d)?$')
> 
> for suitable re-escaping of \
> 
> Don't forget the timezone can be Z.
> 
> Maybe cast it back to an xsd:dateTime.

Thanks. this is really great help.

One more question: Is it possible with the jena functions + regex to get from 
"2015-10-14T11:50:34.583+02:00" to "2015-10-14T11:50:00" ?

I think this should be possible with a combination of your suggestions above 
(STRBEFORE) plus some means to replace the "two characters after the second 
colon with 00". However, I don't know, if it's possible to do that with REGEX?

Thank you very much.

best,
Peter

Reply via email to