Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7756817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:55:11+00:00 2026-06-01T12:55:11+00:00

Given the following query let $a := xs:dateTime(2012-01-01T00:00:00.000+00:00) let $b := xs:dateTime($a) let $c

  • 0

Given the following query

let $a := xs:dateTime("2012-01-01T00:00:00.000+00:00")
let $b := xs:dateTime($a)
let $c := xs:dateTime($a cast as xs:string)
(: cannot - don't know how to - execute the function without assignment :)
let $d := adjust-dateTime-to-timezone($a, xs:dayTimeDuration("PT1H"))
return (<a>{$a}</a>,<b>{$b}</b>,<c>{$c}</c>)

the output is as follows

<a>2012-01-01T01:00:00+01:00</a>
<b>2012-01-01T01:00:00+01:00</b>
<c>2012-01-01T00:00:00Z</c>

Based on XQuery’s documentation on constructor functions (the constructor function for a given type is used to convert instances of other atomic types into the given type) this is the expected behaviour. Calling xs:dateTime($a) simply returns $a as there is no need to cast, but xs:dateTime($a cast as xs:string) creates a new xs:string from $a first. However this requires an extra conversion.

Is there any other way to tackle this problem? Or conversions are cheap and I shouldn’t care?

(If it makes any difference my XQuery processor is BaseX 7.2.)


It seems it does a make a difference that I’m using BaseX. I’ve really thought that this is the way the xs:dateTime constructor function and the adjust-dateTime-to-timezone function should be working, this is why I misinterpreted the XQuery documentation.

Given the input I’ve been given by Dimitre and Ranon it seems the problem described is gone.

By the why my use case is, or more like it was, that I wanted to make a date-time interval based query against my XML data set’s date-time element. Because the input parameters and the source date-time values used different time-zones I had to make time-zone corrections with the above function, which modified its input parameter (the original source date-time in my case), however I wanted to preserve the original value. Given the function’s name adjust-dateTime I thought that it’s okay that it modifies its argument, so I automatically thought that I had to copy my original value using a constructor function to be able to keep the original date-time value.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:55:12+00:00Added an answer on June 1, 2026 at 12:55 pm

    The output that is reported is incorrect.

    The correct output (produced running Saxon under oXygen) is:

    <a>2012-01-01T00:00:00Z</a>
    <b>2012-01-01T00:00:00Z</b>
    <c>2012-01-01T00:00:00Z</c>
    

    The adjust-dateTime-to-timezone() function, as any other function cannot modify its arguments — its effect is only contained in the variable $d — which you don’t use in the return clause.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given following Statment: String query = "Select * from T_spareParts where SparePartPK IN (?
Given the following query, how do I return the p_name with the most transactions?
Given the following recursive query: WITH DepartmentHierarchy (DepartmentID, Name, IsInactive, IsSpecial, ParentId, HierarchyLevel) AS
I have the following SQL query I was given, but I am not sure
Given a query like the following: DELETE FROM FOO WHERE ID in (1,2,3,4,....); Is
Given the following table variable, which contains let's say some 10K records: DECLARE @SomeTable
Given the following tables, how might I build a SQL query that includes a
I am using the bendiken/sparql-client for ruby application.When I execute the given sample query
Given the following MySQL query: SELECT `show`.`id` , GROUP_CONCAT( `showClips`.`clipId` ORDER BY `position` ASC
I have the following query which gives me the right results. But it's super

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.