Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Checking validity of date value

2005-04-27
2012-10-08
  • How do I make sure that a date literal is in proper format before passing it to functions such as "fn:adjust-dateTime-to-timezone" ?
    Such functions throw an exception if the value does not confirm to a valid date literal.
    I need a graceful way of finding out if the value is in incorrect format so that I can proceed without calling the function.

    thanks,
    ananth

     
    • Michael Kay
      Michael Kay
      2005-04-27

      This is exactly what the "castable as" operator is for:

      if ($input castable as xs:dateTime)
      then adjust-dateTime-to-timezone(xs:dateTime($input))
      else f:fofl()

      Michael Kay

       
    • Thanks !
      ananth