Copy codeThe Code is as follows: public function fillzero (l1)
If len (l1) = 1 then
Fillzero = "0" & l1
Else
Fillzero = l1
End if
End function
Usage example:Copy codeThe Code is as follows: response year (now) & month (now) & day (now) Result: 201116
Response year (now) & fillzero (month (now) & fillzero (day (now) display result: 20110106
How to control the display of long and short date formats:
Short Date: FORMATDATETIME (DATE, vb1_date)
Long Date: FORMATDATETIME (DATE, vbLongDate)
When the display date is set based on the UK (US) region, the date is displayed in the following format:
Short Date: 7/9/97
Long Date: Wednesday, July 09,1997
Note: The short date format is displayed exactly the same as that without any formatting. By default, dates are displayed in the short date format.
How to Use the FORMATDATETIME () function to operate the time:
Short Time: FORMATDATETIME (TIME, vb1_time)
Long Time: FORMATDATETIME (TIME, vbLongTime)
When the display time is set in the UK (US) region, the time format is as follows:
Short Time: 03: 20
Long Time: 3: 20: 08 AMCopy codeThe Code is as follows: <%
Function FillZero (str)
Ttt = str
If len (str) = 1 then
Ttt = "0" & str
End if
FillZero = ttt
End function
'Conversion date, add one digit to zero--1-2 -->
Function ConvertDate (tDate)
Ttt = tDate
If isdate (tDate) then
Ttt = year (tDate) & "-" & FillZero (month (tDate) & "-" & FillZero (day (tDate ))
End if
ConvertDate = ttt
End function
'Enter a date and time string and convert it to the four-digit adult, and the other two new date and time strings.
Function ConvertDateTime (tDateTime)
Ttt = tDateTime
If isdate (tDateTime) then
Ttt = year (tDateTime) & "-" & FillZero (month (tDateTime) & "-" & FillZero (day (tDateTime )) & "" & FillZero (cstr (hour (tDateTime) & ":" & FillZero (cstr (minute (tDateTime )))&": "& FillZero (cstr (second (tDateTime )))
End if
ConvertDateTime = ttt
End function
%>