IT/Excel
[엑셀] 오후/오전 포함 데이터 24시간 형식으로 바꾸기
사회복지그래머
2023. 6. 9. 15:49
--ALT + F11 누른 후, 삽입(INSERT) - 모듈
Function ConvertToText(dateTime As String) As String
Dim convertedDateTime As Date
convertedDateTime = CDate(dateTime)
ConvertToText = Format(convertedDateTime, "yyyy-mm-dd hh:mm:ss")
End Function
Format 부분에서 "yyyy-mm-dd hh:mm:ss" 부분을 수정하여
자유롭게 형식 바꾸기 가능하다
ss를 지우면 분까지만 표기되는 등, 요건 엑셀 Ctrl+1 서식과 동일한 것 같다.