## # # PHP # #####
# ³¯Â¥°£ÀÇ Â÷ÀÌ°¡ ¸îÀÏÀÎÁö $days = (strtotime(date("Y-m-d")) - strtotime("2005-12-31")) / (60 * 60 * 24);
# timestamp -> ³¯Â¥ # ³¯Â¥ Æ÷¸Ë º¯°æ $date = date("Y-m-d") $date = date("Y-m-d H:i:s") $date = date("Y-m-d", $timestamp)
# ³¯Â¥ -> timestamp # outputs: 1136930970 # ³¯Â¥ Çü½ÄÀÌ ¸ÂÁö ¾ÊÀ¸¸é -1 ¸®ÅÏ $timestamp = strtotime('2006-01-10 16:09:30');
# Returns the Unix timestamp # ÇöÀçÀÏ¿¡ 30ÀÏÀ» ´õÇÑ ³¯Â¥ $timestamp = mktime(0,0,0, date("m"), date("d")+30, date("Y")); $date = date("Y-m-d", $timestamp)
$day = date("Y-m-d", mktime(0,0,0, 12+1, 1, 2005)); // 2006-01-01 $day = date("Y-m-d", mktime(0,0,0, 12+1, 1-1, 2005)); // 2005-12-31 $day = date("Y-m-d", mktime(0,0,0, 12+1, 1, 2005)-86400); // 2005-12-31
$time = time();
date("Y-m-d",strtotime("-1 day", $time));
date("Y-m-d",strtotime("-1 day", $time));
date("Y-m-d",strtotime("now", $time));
date("Y-m-d",strtotime("+1 day", $time));
date("Y-m-d",strtotime("+1 week", $time));
date("Y-m-d",strtotime("-1 month", $time));
date("Y-m-d",strtotime("+1 month", $time));
date("Y-m-d",strtotime("+6 month", $time));
date("Y-m-d",strtotime("+12 month", $time));
date("Y-m-d",strtotime("next Thursday", $time));
date("Y-m-d",strtotime("last Monday", $time));
date("Y-m-d",strtotime("10 September 2000", $time));
strtotime("+5 minutes") strtotime('first day of')
# ƯÁ¤StringÀ» º¯Çü strtotime("2008-06-25 23:57:33");
# ÇöÀç½Ã°£ °¡Á®¿À±â strtotime("now");
# ¿À´ÃºÎÅÍ ¸î ÀÏÀü(days, months, years µµ »ç¿ë°¡´É) strtotime("-15 days");
# ¿À´ÃºÎÅÍ ¸î ÀÏÈÄ(days, months, years µµ »ç¿ë°¡´É) strtotime("+21 days");
# ƯÁ¤ÀÏ·Î ºÎÅÍ ¸îÀÏÀü/ÈÄ strtotime("+12 days", strtotime("2008-06-25"));
# ÇöÀç ½Ã°£ Ãâ·Â strftime("%Y-%m-%d %H:%M:%S") = 2008-06-25 15:47:58
# ƯÁ¤ÀÏ ½Ã°£ Ãâ·Â strftime("%y.%m.%d %r", strtotime("-15 days")) = 08.06.10 03:47:58 PM
# ¿äÀÏ Ãâ·Â strftime("%d %b %Y %a") = 25 Jun 2008 Wed
# ¿äÀÏ Ãâ·Â strftime("%d %B %Y %A") = 25 June 2008 Wednesday
# Çѱ¹¾î ¿äÀÏ Ãâ·Â setlocale(LC_TIME, "ko_KR"); echo strftime("%a %A"); ¼ö ¼ö¿äÀÏ
# Çѱ¹¾î ¿ù Ãâ·Â setlocale(LC_TIME, "ko_KR"); echo strftime("%b %B"); 6¿ù 6¿ù
# Çѱ¹¾î ½Ã°£ Ãâ·Â setlocale(LC_TIME, "ko_KR"); echo strftime("%r"); ¿ÀÈÄ 03½Ã 47ºÐ 58ÃÊ
## # # MySQL # #####
# ³¯Â¥°£ÀÇ Â÷ÀÌ°¡ ¸îÀÏÀÎÁö datediff(b.sel_day, now()) diff
# ³¯Â¥ ´õÇϱâ
ADDDATE('2007-03-01',3)
ADDDATE('2007-03-01',INTERVAL 3 MONTH)
YEAR, DAY
# ³¯Â¥ Æ÷¸Ë º¯°æ date_format(giil_day, '%Y-%m-%d') giil_day
mysql> SELECT TIMESTAMP('2003-12-31'); -> '2003-12-31 00:00:00' mysql> SELECT TIMESTAMP('2003-12-31 12:00:00','12:00:00'); -> '2004-01-01 00:00:00' mysql> SELECT UNIX_TIMESTAMP(); -> 882226357 mysql> SELECT UNIX_TIMESTAMP('1997-10-04 22:23:00'); -> 875996580 mysql> SELECT FROM_UNIXTIME(1111885200); +---------------------------+ | FROM_UNIXTIME(1111885200) | +---------------------------+ | 2005-03-27 03:00:00 | +---------------------------+
$cur_timestamp = mktime(0,0,0, date("m"), date("d"), date("Y")); $yes_timestamp = mktime(0,0,0, date("m"), date("d")-1, date("Y"));
$sql = " select count(*) tot_num, sum(reg_date >= $yes_timestamp and reg_date < $cur_timestamp) yes_num, sum(reg_date >= $cur_timestamp) cur_num from zetyx_member_table "; $iv_row = @mysql_fetch_array(mysql_query($sql)); ?>
## # # MS-SQL # #####
mssql convert
Conversion to char functions
We outline now the conversions to strings from all the data types (we only specify the MS-SQL Server version of the interpretation of the functions):
Option name in the popup list Inserted string (where Fld is the selected field) Float [6-digit] CONVERT(VARCHAR, Fld, 0) Float [8-digit Scientific] CONVERT(VARCHAR, Fld, 1) Float [16-digit Scientific] CONVERT(VARCHAR, Fld, 2) Other Numeric CONVERT(VARCHAR, Fld) Currency [9999.99] CONVERT(VARCHAR, Fld, 0) Currency [9,999.99] CONVERT(VARCHAR, Fld, 1) Currency [9999.9999] CONVERT(VARCHAR, Fld, 2) Date-Time [mm/dd/yy] CONVERT(VARCHAR, Fld, 1) Date-Time [mm/dd/yyyy] CONVERT(VARCHAR, Fld, 101 ) Date-Time [yy.mm.dd] CONVERT(VARCHAR, Fld, 2) Date-Time [yyyy.mm.dd] CONVERT(VARCHAR, Fld, 102) Date-Time [dd/mm/yy] CONVERT(VARCHAR, Fld, 3) Date-Time [dd/mm/yyyy] CONVERT(VARCHAR, Fld, 103 ) Date-Time [dd.mm.yy] CONVERT(VARCHAR, Fld, 4) Date-Time [dd.mm.yyyy] CONVERT(VARCHAR, Fld, 104 ) Date-Time [dd-mm-yy] CONVERT(VARCHAR, Fld, 5) Date-Time [dd-mm-yyyy] CONVERT(VARCHAR, Fld, 105) Date-Time [dd mon yy] CONVERT(VARCHAR, Fld, 6) Date-Time [dd mon yyyy] CONVERT(VARCHAR, Fld, 106) Date-Time [Mon dd, yy] CONVERT(VARCHAR, Fld, 7) Date-Time [Mon dd, yyyy] CONVERT(VARCHAR, Fld, 107) Date-Time [mm-dd-yy] CONVERT(VARCHAR, Fld, 10) Date-Time [mm-dd-yyyy] CONVERT(VARCHAR, Fld, 110 ) Date-Time [yy/mm/dd] CONVERT(VARCHAR, Fld, 11) Date-Time [yyyy/mm/dd] CONVERT(VARCHAR, Fld, 111 ) Date-Time [yymmdd] CONVERT(VARCHAR, Fld, 12) Date-Time [yyyymmdd] CONVERT(VARCHAR, Fld, 112) Date-Time [mon dd yyyy hh:miAM] CONVERT(VARCHAR, Fld, 0) Date-Time [mon dd yyyy hh:mi:ss:mmmAM] CONVERT(VARCHAR, Fld, 9) Date-Time [dd mon yyyy hh:mm:ss:mmm] CONVERT(VARCHAR, Fld, 13) Date-Time [hh:mm:ss] CONVERT(VARCHAR, Fld, 8) Date-Time [hh:mi:ss:mmm] CONVERT(VARCHAR, Fld, 14) Date-Time [yyyy-mm-dd hh:mi:ss] CONVERT(VARCHAR, Fld, 20) Date-Time [yyyy-mm-dd hh:mi:ss.mmm] CONVERT(VARCHAR, Fld, 21) Date-Time [yyyy-mm-ddThh:mm:ss:mmm] CONVERT(VARCHAR, Fld, 126 )
# ¼ÒÆ® : ÁÖ + È÷Æ®¼ö
sSQL = " SELECT TOP 6 ID " sSQL = sSQL & " , CODE " sSQL = sSQL & " , TITLE " sSQL = sSQL & " , HIT " sSQL = sSQL & " , ASSIST " sSQL = sSQL & " , IPADDRESS " sSQL = sSQL & " , create_date " sSQL = sSQL & " , datepart(yy, create_date)*100+datepart(wk, create_date) as sorttmp " sSQL = sSQL & " FROM TB_GBOARD_006 " sSQL = sSQL & " WHERE GUBUN = 'A' " sSQL = sSQL & " ORDER BY sorttmp desc, HIT DESC "
sSQL = " SELECT TOP 6 ID " sSQL = sSQL & " , CODE " sSQL = sSQL & " , TITLE " sSQL = sSQL & " , HIT " sSQL = sSQL & " , ASSIST " sSQL = sSQL & " , IPADDRESS " sSQL = sSQL & " , create_date " sSQL = sSQL & " , convert(char, datepart(yy, create_date))+ " sSQL = sSQL & " convert(char,datepart(wk, create_date)) as sorttmp " sSQL = sSQL & " FROM TB_GBOARD_018 " sSQL = sSQL & " WHERE GUBUN = 'A' " sSQL = sSQL & " ORDER BY sorttmp desc, HIT DESC "
|