00001 ' Attribute VB_Name = "DateUtil" 00002 '! @brief 日付型編集の為の関数群。 00003 00004 '----------------------------------------------------------- 00005 '* @brief 日付型編集 yyyy/MM/dd HH:mm:ss フォーマット固定。 00006 '----------------------------------------------------------- 00007 Public Function FormatFullDate(invalue) 00008 Dim buf 00009 00010 buf = Right("0000" & Replace( FormatNumber(Year(invalue)) ," ",""),4) _ 00011 & "/" & Right("00" & Replace( FormatNumber(Month(invalue)) ," ",""),2) _ 00012 & "/" & Right("00" & Replace( FormatNumber(Day(invalue)) ," ",""),2) _ 00013 & " " & Right(" 00" & Replace( FormatNumber(Hour(invalue)) ," ",""),2) _ 00014 & ":" & Right(" 00" & Replace( FormatNumber(Minute(invalue)) ," ",""),2) _ 00015 & ":" & Right(" 00" & Replace( FormatNumber(Second(invalue)) ," ",""),2) 00016 End Function 00017 00018 '----------------------------------------------------------- 00019 '* @brief 日付型編集 yyyyMMddHHmmss フォーマット固定。 00020 '----------------------------------------------------------- 00021 Public Function FormatFullDateNoDelim(invalue) 00022 Dim buf 00023 00024 buf = Right("0000" & Replace( FormatNumber(Year(invalue)) ," ",""),4) _ 00025 & "" & Right("00" & Replace( FormatNumber(Month(invalue)) ," ",""),2) _ 00026 & "" & Right("00" & Replace( FormatNumber(Day(invalue)) ," ",""),2) _ 00027 & "" & Right(" 00" & Replace( FormatNumber(Hour(invalue)) ," ",""),2) _ 00028 & "" & Right(" 00" & Replace( FormatNumber(Minute(invalue)) ," ",""),2) _ 00029 & "" & Right(" 00" & Replace( FormatNumber(Second(invalue)) ," ",""),2) 00030 End Function 00031 00032 00033 '----------------------------------------------------------- 00034 '* @brief 日付型編集 yyyy/MM/dd HH:mm:ss 00035 '* @param invalue Dateの値 00036 '* fmt フォーマット文字列。書式はjava.text.SimpleDateFormatに従う 00037 '* yyyy 4桁の西暦 00038 '* yy 西暦下2桁 00039 '* MM 月(必ず2桁0埋め) 00040 '* M 月(0除外) 00041 '* dd 日(必ず2桁0埋め) 00042 '* d 日(0除外埋め) 00043 '* hh 時(必ず2桁0埋め24時) 00044 '* mm 分(必ず2桁0埋め) 00045 '* ss 秒(必ず2桁0埋め) 00046 '----------------------------------------------------------- 00047 Public Function FormatDate(invalue,fmt) 00048 Dim buf 00049 00050 If IsNull(invalue) Then 00051 FormatDate = Null 00052 Exit Function 00053 End If 00054 buf = fmt 00055 00056 If InStr(buf,"yyyy") > 0 Then 00057 buf = Replace(buf,"yyyy", Right("0000" & CStr(Year(invalue)),4) ) 00058 End If 00059 00060 If InStr(buf,"yy") > 0 Then 00061 buf = Replace(buf,"yy", Right("0000" & CStr(Year(invalue)),2) ) 00062 End If 00063 If InStr(buf,"MM") > 0 Then 00064 buf = Replace(buf,"MM", Right("00" & CStr(Month(invalue)),2) ) 00065 End If 00066 If InStr(buf,"M") > 0 Then 00067 buf = Replace(buf,"M", CStr(Month(invalue)) ) 00068 End If 00069 If InStr(buf,"dd") > 0 Then 00070 buf = Replace(buf,"dd", Right("00" & CStr(Day(invalue)),2) ) 00071 End If 00072 If InStr(buf,"d") > 0 Then 00073 buf = Replace(buf,"d", CStr(Day(invalue)) ) 00074 End If 00075 00076 If InStr(buf,"HH") > 0 Then 00077 buf = Replace(buf,"HH", Right("00" & CStr(Hour(invalue)),2) ) 00078 End If 00079 If InStr(buf,"mm") > 0 Then 00080 buf = Replace(buf,"mm", Right("00" & CStr(Minute(invalue)),2) ) 00081 End If 00082 If InStr(buf,"ss") > 0 Then 00083 buf = Replace(buf,"ss", Right("00" & CStr(Second(invalue)),2) ) 00084 End If 00085 00086 00087 FormatDate = buf 00088 End Function