package ua.com.fielden.platform.entity.query.generation.elements;

import ua.com.fielden.platform.entity.query.generation.DbVersion;


public class DateOf extends SingleOperandFunction {

    public DateOf(final ISingleOperand operand, final DbVersion dbVersion) {
	super(dbVersion, operand);
    }

    @Override
    public String sql() {
	switch (getDbVersion()) {
	case H2:
	case MSSQL:
	case POSTGRESQL:
	    return "DATE_PART('day', " + getOperand().sql() + ")";
	default:
	    throw new IllegalStateException("Function [" + getClass().getSimpleName() +"] is not yet implemented for RDBMS [" + getDbVersion() + "]!");
	}
    }
}
@@ -375,19 +375,150 @@
 2:%0A%09
-case MSSQL:
+    return %22CAST(%22 + getOperand().sql() + %22 AS DATE)%22;%0A%09case MSSQL:%0A%09    return %22DATEADD(dd, DATEDIFF(dd, 0, %22 + getOperand().sql() + %22), 0)%22;
 %0A%09ca
@@ -554,12 +554,13 @@
 ATE_
-PART
+TRUNC
 ('da

Corrected.