title: Axapta 2012 - Ax Views and GETDATE()
body: <p>I'm trying to make a date range in a view work relative to today. But I'm not find any function to set in the query range to make it dynamic.</p>
  
  <p>Example:
  <a href="https://i.stack.imgur.com/HCfBn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HCfBn.png" alt="enter image description here"></a></p>
  
  <p>Creates:</p>
  
  <pre><code>SET ANSI_NULLS ON
  GO
  
  SET QUOTED_IDENTIFIER ON
  GO
  
  CREATE VIEW [dbo].[MYCUSTINVOICETABLEVIEW] AS 
  SELECT T1.INVOICEID AS INVOICEID,T1.DATAAREAID AS DATAAREAID,T1.PARTITION AS PARTITION,T1.RECID AS RECID 
  FROM CUSTINVOICETABLE T1
  WHERE (INVOICEDATE&lt;={ts '2017-07-18 00:00:00.000'})
  GO
  </code></pre>
  
  <p>But instead of looking relative to <em><code>last synchronization date</code></em>, I want to look compared to <em><code>today</code></em>.</p>
  
  <pre><code>SELECT ... FROM CUSTINVOICETABLE T1
  WHERE (INVOICEDATE&lt;=GETDATE())
  </code></pre>
  
  <p>Any ideas how I can setup the query ranges for this?</p>
  
  <hr>
  
  <p>Tried so far:</p>
  
  <ul>
  <li>..GetDate()</li>
  <li>..today()</li>
  <li>..currentDate()</li>
  <li>lessThanDate(0)</li>
  <li>"&lt; GETDATE()"</li>
  <li>&lt; currentSessionDateTime() </li>
  </ul>
  
  <p>According to <a href="https://stackoverflow.com/questions/42549908/how-to-refresh-synch-view-based-on-a-query-with-dynamic-range">How to refresh/Synch View based on a Query with dynamic range?</a>, it's not possible (for UserID()). I want to double check if that's the same case for dates. The view is being consumed by a other application on the same box (not an Ax form).</p>