|
|
|
|
²ÀÁö / 2003-04-18 / ¿ÀÀü 10:31:55 / 203.244.220.254
Á¶È¸¼ö : 189
|
[Áú¹®] FSO.DateCreated ³¯Â¥¸¦ SQL datetime¿¡ ÀúÀåÇÏ·Á¸é? |
²ÀÁö »ý°¢À» Àû¾î º¾´Ï´Ù.
ÀÏ´Ü datetime Çü½ÄÀÇ Ä÷³Àº ¸»±×´ë·Î ³¯Â¥ Çü½ÄÀ¸·Î µé¾î °¡¾ß ÇÕ´Ï´Ù.
³¯Â¥Çü½ÄÀº DBMS°¡ ÀνÄÇÒ ¼ö ÀÖ´Â Çü½ÄÀ¸·Î µé¾î °¡¾ß Çϴµ¥, À̶§ '¿ÀÀü' '¿ÀÈÄ'µîÀº À¯´ÏÄÚµå Çü½ÄÀ̱⶧¹®¿¡ ÀÎ½ÄµÉ ¼ö ¾ø´Â °ÍÀ¸·Î ¾Ë°í ÀÖ½À´Ï´Ù.
µû¶ó¼ Àû´çÇÑ ³¯Â¥ Çü½ÄÀ¸·Î ¹Ù²ã Áà¾ß ÇÏ´Â ÀÛ¾÷ÀÌ ÇÊ¿äÇÒ°Å °°½À´Ï´Ù.
¾Æ·¡ÀÇ Äڵ带 Âü°íÇϼ¼¿ä.
ÄÚµå 1¿¡¼´Â
³â ¿ù ÀÏ ½Ã ºÐ ÃÊ
ÇüÅ·Π¹Ù²Ù´Â ÀÛ¾÷À» Ãß°¡ÇÏ¸é ´õ¿í Á¤È®ÇÑ µ¥ÀÌÅÍ°¡ µÉ ¼ö ÀÖ°Ú½À´Ï´Ù.
¢Ã ¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬ ÄÚµå 1 ¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬
<%
strCon = "Provider=SQLOLEDB.1;Password=5070;Persist Security Info=True;User ID=sa;Initial Catalog=TEST;Data Source=¼Á¤¼ö"
Set objCon = Server.CreateObject("ADODB.Connection")
objCon.Open strCon
dteDate = CDate("2003-04-10 ¿ÀÈÄ 6:45:03")
'dteDate = FormatDateTime(dteDate, 2) & " " & FormatDateTime(dteDate, 4)
dteDate = FormatDateTime(dteDate ,2) & " " & Right("0" & Hour(dteDate), 2) & ":" & Right("0" & Minute(dteDate), 2) & ":" & Right("0" & Second(dteDate), 2)
'Insert Into CDate (cDate) Values ('2003-04-10 18:45')
strQuery = "Insert Into CDate (cDate) Values ('"& dteDate &"')"
objCon.Execute strQuery
objCon.Close
Set objCon = Nothing
%>
¢Ã ¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬ ÄÚµå 2 ¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬
/**********************************************************************/
/******* datetime ¹× smalldatetime *********/
/**********************************************************************/
------------------------------------------------------------------------
-- ¢Ã Datetime°ú smalldatetime¿¡ °ªÀ» ´ëÀÔÇϱ⠹æ¹ýÀ» º¸ÀÚ.
USE TempDB
IF OBJECT_ID('TestDateType') IS NOT NULL
DROP TABLE TestDateType
GO
Create Table TestDateType
(Date1 smalldatetime
,Date2 datetime
,Date3 datetime)
GO
INSERT TestDateType VALUES(0 , 1.25 ,'1970')
INSERT TestDateType VALUES('20011225' , '2001.12.25', '2001-12-25')
INSERT TestDateType VALUES('9/10/1999','1999.09.10' ,'1999-09-12 15:15:15:150')
INSERT TestDateType VALUES(GetDate() ,GetDate()+1 ,DateAdd(month,1,GetDate()))
SELECT * FROM TestDateType
GO
>
> ¾È³çÇϽʴϱî? °í¼öºÐµé....
>
> Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
> Set objFile = objFSO.GetFolder(Server.MapPath(strPath))
> strBirth = fileItem.DateCreated
>
> Çϸé strBirth´Â ´ÙÀ½°ú °°Àº ÇüÅÂÀÇ °ªÀ» °¡Áö°Ô µË´Ï´Ù.
>
> 2003-04-10 ¿ÀÈÄ 6:45:03
>
> ÀÌ ³¯Â¥¸¦ SQL ¼¹öÀÇ datetime(8) ¿¡ ´ÙÀ½°ú °°ÀÌ Insert¸¦ Çϸé
>
> strSQL = "insert into TEST (name, datenow) " & _
> " values ('"& strName &"', '"& DateValue(strBirth) &"')"
>
>
> " Microsoft OLE DB Provider for SQL Server (0x80040E57)
> ¹®ÀÚ¿À̳ª ÀÌÁø µ¥ÀÌÅÍ´Â À߸³´Ï´Ù. "
>
> ¶ó´Â ¿¡·¯¸Þ½ÃÁö°¡ ³ª¿É´Ï´Ù. ¿¡·¯¸Þ½ÃÁö°¡ ³ª¿À±ä ÇÏÁö¸¸ Å×À̺íÀÇ ³»¿ëÀ» º¸¸é
> µÞºÎºÐ ½Ã°£µ¥ÀÌÅÍ´Â Àß·ÁÁö°í ¾ÕºÎºÐ ³¯Â¥ ºÎºÐ¸¸ ÀԷµǾî ÀÖ½À´Ï´Ù.
>
> 2003-04-10 00:00:00.000
>
> ÀÌ·¸°Ô ÀÔ·ÂÀÌ µË´Ï´Ù.
>
> ÀÌ·²°æ¿ì ¾î¶»°Ô Çϸé Á¤È®ÇÑ datetimeÀ» ÀÔ·ÂÇÒ ¼ö ÀÖ´ÂÁö¿ä?
>
----------------------------------------------------------- |
|
|
|