2011年6月7日 星期二

Oracle 欄位合併

SELECT T.SDATE , T.YM ||'/'|| N.YM AS YM from DAILY

select userid, concat(surname,name) as your_name from user;

2011年5月16日 星期一

mysql FROM_UNIXTIME

SELECT UNIX_TIMESTAMP('2005-03-27 03:00:00');
1111885200
SELECT UNIX_TIMESTAMP('2005-03-27 02:00:00');
1111885200
SELECT FROM_UNIXTIME(1111885200);
2005-03-27 03:00:00 
-------------------------

select 
FROM_UNIXTIME(SUBSTRING(stime,1,10)),FROM_UNIXTIME(SUBSTRING(stime,1,10)),time
from e;

2011年5月6日 星期五

Java 毫秒轉日期

public static void main(String[] args) throws SQLException, ClassNotFoundException, ParseException {
     String x = "1304638584000";
     long l = new Long(x).longValue();
     System.out.println("Long value: " + l);
     Calendar c = new GregorianCalendar();
     c.setTimeInMillis(l);  
     String origDate =
     c.get(Calendar.YEAR) + "-" +
     c.get(Calendar.MONTH) + "-" +
(c.get(Calendar.MONTH)+1)+ "-" +  +" " +
     c.get(Calendar.HOUR)+":"+c.get(Calendar.MINUTE)+":"+c.get(Calendar.SECOND)
     ;
     System.out.println("Date in YYYY-MM-DD format: " + origDate);
    }