HouSong/squiggle-sql

to_date function

Opened this issue · 1 comments

I need to create a sql statement as below

select * from <table>
where <column> = To_Date('2009-07-31','YYYY-MM-DD')

How do i do this ??



Original issue reported on code.google.com by madh...@gmail.com on 22 Jul 2010 at 9:11

This will do the trick:

        Table table = new Table("table");
        Column c = new Column(table, "column");

        FunctionCall func = new FunctionCall("To_Date", 
                new StringLiteral("2009-07-31"),
                new StringLiteral("YYYY-MM-DD"));

        SelectQuery q = new SelectQuery();
        q.addToSelection(new WildCardColumn(table));

        q.addCriteria(new MatchCriteria(c, MatchCriteria.EQUALS, func));


By the way, this was not an "Issue". You would have better used the discussion 
group.

Original comment by brunoabdon on 6 Aug 2010 at 4:50