20201007 0837 

 

"docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/format-function-visual-basic-for-applications"

 

Dim MyTime, MyDate, MyStr
MyTime = #17:04:23#
MyDate = #January 27, 1993#

' Returns current system time in the system-defined long time format.
MyStr = Format(Time, "Long Time")

' Returns current system date in the system-defined long date format.
MyStr = Format(Date, "Long Date")

MyStr = Format(MyTime, "h:m:s")    ' Returns "17:4:23".
MyStr = Format(MyTime, "hh:mm:ss am/pm")    ' Returns "05:04:23 pm".
MyStr = Format(MyTime, "hh:mm:ss AM/PM")    ' Returns "05:04:23 PM".
MyStr = Format(MyDate, "dddd, mmm d yyyy")    ' Returns "Wednesday, Jan 27 1993".
' If format is not supplied, a string is returned.

Time 대신에 Now를 써도 된다.

'[PA] 업무자동화 > [XL]Excel & VBA' 카테고리의 다른 글

XL sendkeys, shell, running app using VBA  (0) 2020.10.22
XL Last Cell 다루기  (0) 2020.10.08
XL Group Pivot Table  (0) 2020.10.07
XL Copy and Paste a Range  (0) 2020.10.07
XL Cells를 이용한 Range 선택  (0) 2020.10.07
Posted by Weneedu
,


출처: https://privatedevelopnote.tistory.com/81 [개인노트]