Thank you for the answer.

I am looking at the source code H2 more specific Function.java
and I see that a couple of functions are initially set with Value.NULL 
(since at that time the return data type is not known) 

Although there is a method called optimize 
that is used that for some functions the correct return data type is 
calculated.

Could the same be done to the formula DATE_TRUNC in optimize?
Do you agree?

Our system connects to multiple database systems and depends a lot on the 
data type being returned 
(the SQL code is written by our users). 

In my view, a NULL data type is a bit ambiguous for this cases comparing 
with other systems with the same function date_trunc 
like PostgreSQL that always returns the correct type.


Thank you for your time. 


Pedro

On Thursday, 28 June 2018 14:31:39 UTC+1, Evgenij Ryazanov wrote:
>
> Hello.
>
> This function in H2 does not have exact return type, it may return 
> TIMESTAMP, TIMESTAMP WITH TIME ZONE, DATE, or TIME depending on type of the 
> second argument. That's why its return type is not defined. You can add an 
> explicit cast.
> SELECT CAST(DATE_TRUNC('MONTH', column) AS TIMESTAMP)
> This construction looks ugly, but it should return an expected column type 
> in meta data.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to