Answer the question
In order to leave comments, you need to log in
How to make a function for EXCEL from a PHP script?
How to make a function for EXCEL from a PHP script?
Let's say we have a PHP script:
$str = '921205400655';
list($year, $month, $day) = sscanf($str, "%2d%2d%2d");
if ($year > 30) $year = 1900 + $year;
else $year = 2000 + $year;
$date = sprintf("%04d.%02d.%02d", $year, $month, $day);
echo $date;
Answer the question
In order to leave comments, you need to log in
I sketched an example in VBA, the code needs to be saved in an Excel template. To start, find and run the "GetDate" macro - a window will pop up for entering the string "921205400655", and by clicking on "OK" the date will be added to the active sheet in the previously selected cell:
Function GetDate(ByVal str As String)
Dim day As String, month As String, year As String
year = Left(str, 2)
month = Mid(str, 3, 2)
day = Mid(str, 5, 2)
If year > 30 Then year = year + 1900 Else year = year + 2000
GetDate = year & "." & month & "." & day
End Function
Sub ПолучитьДату()
Dim result As String
On Error Resume Next
result = InputBox("Введите число", "Диалоговое окно", "921205400655")
ActiveCell = GetDate(result)
End Sub
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question