Search in sources :

Example 1 with AstNumericConstant

use of com.developmentontheedge.sql.model.AstNumericConstant in project be5 by DevelopmentOnTheEdge.

the class SqlServerTransformer method transformDateTrunc.

@Override
protected void transformDateTrunc(AstFunNode node) {
    AstStringConstant child = (AstStringConstant) node.child(0);
    String dateformat = child.getValueUnescaped();
    AstIdentifierConstant datepart = new AstIdentifierConstant(dateformat);
    AstNumericConstant date = AstNumericConstant.of(0);
    node.replaceWith(DATEADD.node(datepart, DATEDIFF.node(datepart, date, node.child(1)), date));
}
Also used : AstIdentifierConstant(com.developmentontheedge.sql.model.AstIdentifierConstant) AstNumericConstant(com.developmentontheedge.sql.model.AstNumericConstant) AstStringConstant(com.developmentontheedge.sql.model.AstStringConstant)

Aggregations

AstIdentifierConstant (com.developmentontheedge.sql.model.AstIdentifierConstant)1 AstNumericConstant (com.developmentontheedge.sql.model.AstNumericConstant)1 AstStringConstant (com.developmentontheedge.sql.model.AstStringConstant)1