我需要从列中获取Minmum和Maximum Date。 但我总是得到时间格式的结果,如12.00.00 AM
我用于此的代码Whicch如下所示
Dim Sheet12 As Worksheet
Dim Mesh_Range As Range
Set Sheet12 = ThisWorkbook.Sheets("DATA_SHEET")
Sheet12.Activate
Dim Min_Date As Date
Dim Max_Date As Date
Min_Date = Application.WorksheetFunction.Min(Columns("A"))
Max_Date = Application.WorksheetFunction.Max(Columns("A"))
我还将列值附加为我试过的Image。
请帮我解决这个问题。 提前致谢 作者:Suresh Vijayan enter image description here
答案 0 :(得分:0)
运行此程序。它会正确地输入正确的最小值/最大值,或 如果输入的日期不正确,它会显示输入它们的正确方法:
json_encode($request->input('qualification'), JSON_FORCE_OBJECT)
需要以适合您的区域设置的格式输入日期。如果你有很多错误输入的日期,你可以修复"他们有这个功能:
Sub testDates()
Dim Sheet12 As Worksheet
Dim Min_Date As Date
Dim Max_Date As Date
Set Sheet12 = ThisWorkbook.Sheets("DATA_SHEET")
Min_Date = Application.WorksheetFunction.Min(Sheet12.Columns("A"))
Max_Date = Application.WorksheetFunction.Max(Sheet12.Columns("A"))
If Not IsDate(Min_Date) Or Min_Date < 10000 Then
MsgBox "No dates found. Maybe it's incorrectly stored as text?" & vbLf & vbLf & _
"The correct way to enter a date is one of these two ways:" & vbLf & _
" SHORT DATE FORMAT: " & Format(Now(), "Short Date") & vbLf & _
" LONG DATE FORMAT: " & Format(Now(), "Long Date")
Else
MsgBox "Dates Found!" & vbLf & vbLf & _
"Min: " & Min_Date & vbLf & "Max: " & Max_Date
End If
End Sub
您可以从VBA调用该函数,也可以直接在工作表上调用,如:
Public Function DateFromText(str As String) As Date
'converts text in D-MMM-YY format to a Date
Dim strOut As String
strOut = Split(str, "-")(1) & " " & Split(str, "-")(0) & " 20" & Split(str, "-")(2)
If Not IsDate(strOut) Then Exit Function
DateFromText = DateValue(strOut)
End Function