I am a newbie in xquery and one of the requirement is to generate daily reports by querying xDB.
If I hardcode the date I am able to generate the report from xDB but if I try to read the current Date the from the system I don't get any values in report.
Code Snippet:
let $day := fn:current-date()
let $hours := ( '00', '01', '02', '03', '04',
'05', '06', '07', '08', '09',
'10', '11', '12', '13', '14',
'15', '16', '17', '18', '19',
'20', '21', '22', '23' )
let $ddhh := for $i in $hours return concat($day,"T",$i)
let $title := concat("Average Time By Documents in Hour on ", $day)
In report: ("Average Time By Documents in Hour on 2015-06-08Z"..)
The difference between hardcoded value and current-date() function is the timezone"Z". How do I get rid of timezone "Z". I only want say "2015-06-08" in variable $day and not "2015-06-08Z"
Thanks in advance.
When casting a dateTime object to a string, the default ISO date format is chosen, always including the timezone. Convert the date manually instead using
fn:format-dateTime($dateTime, $picture)
with a date picture string$picture
.You can also add the hours in the desired format:
This even enable you to omit the hour-sequence you pregenerated (of course also works in a single line, split up so it can be explained more easily):