当同一列中的不同格式转换为日期

时间:2016-07-05 06:16:21

标签: sql postgresql

我遇到了一个包含两种不同格式的日期(存储为文本)的列。使用to_date()需要指定格式,因此它只适用于其中一些格式。

有没有办法与SELECT并行转换这两种格式?

{{1}}

1 个答案:

答案 0 :(得分:0)

(假设只有2种不同类型的日期格式) 分别处理两种格式并使用UNION ALL进行组合。

public class ClickHandler {

    public RecyclerView.OnItemTouchListener touchListener;

    public ClickHandler(){
        //initialize the instance of your touchListener in the constructor
        touchListener = new RecyclerView.SimpleOnItemTouchListener(){
            @Override
            public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e)     {
                //allow clicks
                return true;
            }

            @Override
                public void onTouchEvent(RecyclerView rv, MotionEvent e) {
                //check if it is working / check if we get the touch event:
                Log.d("onTouchEvent", "RecView: " + rv.getId() + "\nMotionEvent: "+ e.getAction());
            }
        };
    }

    /* last but not least: a method which returns the touchlistener. 
       You can rename the method, but don't forget to rename the attribute in the xml, too. */
    public RecyclerView.OnItemTouchListener touchListener(){
        return touchListener;
    }
}

所以你需要弄清楚的是2格式说明符字符串。 (我现在无法访问postgre数据库)

相关问题