title: XPath - is a date null
body: <p>Using XPath, how do I figure out if a date or datetime field is null or blank?</p>
  
  <p>I am using the concat method as a stand-in for the XPath if statement</p>
  
  <pre><code>concat(
  substring(../preceding-sibling::my:PerDiem[1]/my:perDiemEnd, 1, ../preceding-sibling::my:PerDiem[1]/my:perDiemEnd = "" * string-length(../preceding-sibling::my:PerDiem[1]/my:perDiemEnd)),
  substring(/my:ExpenseForm/my:ExpenseHeader/my:departureDateTime, 1, not(../preceding-sibling::my:PerDiem[1]/my:perDiemEnd = "") * string-length(/my:ExpenseForm/my:ExpenseHeader/my:departureDateTime))
  )
  </code></pre>
  
  <hr>
  
  <p>More info:
  In Infopath 2010, a repeating table has two date/time fields called perDiemStart and perDiemEnd.  In the repeating table, the next perDiemStart is the previous perDiemEnd.  This is easily done if the default value of perDiemStart is <code>../preceding-sibling::my:PerDiem[1]/my:perDiemEnd</code></p>
  
  <p>But for the first perDiemStart (since a previous perDiemEnd does not exist, I suppose it would be null/blank).  I want that first (blank) value to be a different: value of departureDateTime node</p>
  
  <p>Node locations:</p>
  
  <p><code>/my:ExpenseForm/my:ExpenseHeader/my:departureDateTime</code> </p>
  
  <p><code>/my:ExpenseForm/my:PerDiemDetails/my:PerDiems/my:PerDiem/my:perDiemStart</code></p>
  
  <p><code>/my:ExpenseForm/my:PerDiemDetails/my:PerDiems/my:PerDiem/my:perDiemEnd</code></p>