mysql - How to define a date interval in a compatible way? -


I am trying to create SQL query, which is both on HSQL V2 .2.4) and MySQL (v5.1.36) server (if this can also run on DB2V9, this would be a wonderful bonus!)

is the query:

  Select the document count (*), where current_data - cast (date indexed as date) & lt; =?   

(here current_date is a standard HSQL / MySQL function and indexing_date is a column type datetime Parameter ? is replaced by integer 20 ).

The problem is that MySQL gives the difference between the date while HSQL returns

Additionally HSQL supports this syntax (but not MySQL):

 Select the  count (*) from the document where the date (indexing_date as date) is current_data - between 20 days and the current date   

While MySQL does not do I have information in MySQL Let me, but as I said the solution should be interoperated.

HSQLda also supports it:

  (*) Where current_data - cast (indexing_date as date) & lt; Select cast (*) from = cast (in the form of interval day)   

and

  document where the date (date format) between the current date In index date) - '20' day and current_data   

or

  select count (*) from document where indexing_date & gt; = Current_date - Interval '20' day   

In addition to version 2.2.6, HSQLDB supports DATEDIFF (Datewalla, DebVilube) , which is two Returns the number of days between dates, as well as day (datewise) , which gives the number of days since the era.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

c# - Confused over DLL entry points (entry point not found exception) -