=IF(D1>=DATE(2019,5,1),"令和"&IF(YEAR(D1)-2018=1,"元",YEAR(D1)-2018)&"年"&MONTH(D1)&"月"&DAY(D1)&"日",TEXT(D1,"ggge年m月d日"))
※数式の中の「D1」は実際日付が書いてあるセルです、そこは適当に変更してください。
※「令和元年」ではなく「令和1年」として表示したければ、「IF(YEAR(D1)-2018=1,"元",」を削除し、「-2018)&"年"」の中の「)」も削除すればOK
=IF(D1>=DATE(2019,5,1),"令和"&IF(YEAR(D1)-2018=1,"元",YEAR(D1)-2018)&"年"&MONTH(D1)&"月"&DAY(D1)&"日",TEXT(D1,"ggge年m月d日"))
/* $csvPath: CSV file path
* $firstRowAsKey: whether make the first row as key horizontally. or just number, duplicate will not be over writed
* $columnAsKey: whether to set key(column name or column index) column vertically. or just number, duplicate will not be over writed
* $columnAsVal: Array or Single Column name or column index from 0, whether to filte columns
* $smartFlat:if horizontally array only have one key, then falt it.
*
* For Example: CSV(this methord will take care of sjis utf8 encode problem)
* name,point
* Joe,2
* Peter,321
* Jane,34
*
* $firstRowAsKey = true, $columnAsKey = null, $columnsAsVal = null
* Array([0] => Array([name] => Joe, [point] => 2), [1] => Array([name] => Peter,[point] => 321), [2] => Array([name] => Jane, [point] => 34))
*
* firstRowAsKey = false, $columnAsKey = 0, $columnsAsVal = null
* Array([name] => Array([0] => name, [1] => point), [Joe] => Array([0] => Joe, [1] => 2), [Peter] => Array([0] => Peter, [1] => 321), [Jane] => Array([0] => Jane, [1] => 34))
*
* firstRowAsKey = true, $columnAsKey = 'name', $columnsAsVal = point
* Array([Joe] => Array([point] => 2), [Peter] => Array([point] => 321), [Jane] => Array([point] => 34))
*/
function readArrayCSV($csvPath, $firstRowAsKey = true, $columnAsKey = null, $columnsAsVal = null, $smartFlat = true) {
$sjis = file_get_contents($csvPath);
$utf8 = mb_convert_encoding($sjis, 'UTF-8', 'SJIS-win');
$temp = tempnam(sys_get_temp_dir(), 'TMP_');
file_put_contents($temp, $utf8);
$csv = file($temp, FILE_IGNORE_NEW_LINES);
if ($firstRowAsKey) {
$titles = explode(",", array_shift($csv));
$csv = array_map('str_getcsv', $csv);
$csv = array_map(function ($row) use ($titles) {
return array_combine($titles, $row);
},$csv);
} else {
$csv = array_map('str_getcsv', $csv);
}
if ($columnAsKey !== null) {
$result = array();
if (is_int($columnAsKey) && $columnAsKey > 0) $columnAsKey--;
foreach ($csv as $row) {
if (isset($row[$columnAsKey])) {
$row_filtered = $row;
if ($columnsAsVal !== null) {
$row_filtered = array_intersect_key($row, array_flip((array)$columnsAsVal));
}
$result[$row[$columnAsKey]] = ($smartFlat?(count($row_filtered) == 1?array_shift(array_values($row_filtered)):$row_filtered):$row_filtered);
}
}
} else {
$result = $csv;
}
return $result;
}
SELECT * FROM
(
SELECT * FROM `table`
ORDER BY AnotherColumn
) t1
GROUP BY SomeColumn
;
SELECT somecolumn, anothercolumn
FROM sometable
WHERE id IN (
SELECT min(id)
FROM sometable
GROUP BY somecolumn
);
'//Bath Print multiple pdfs without the first page
'//複数PDFを一括印刷する、PDF毎の一枚目は飛ばす。ドラッグアンドドロップでできます
set WshShell = CreateObject ("Wscript.Shell")
set fs = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
if objArgs.Count < 1 then
msgbox("Please drag a file on the script")
WScript.quit
end if
Set gApp = CreateObject("AcroExch.App")
gApp.show '<- br="" comment="" hidden="" in="" mod="" or="" out="" take="" to="" work="">
'open via Avdoc and print
for i=0 to objArgs.Count - 1
FileIn = ObjArgs(i)
Set AVDoc = CreateObject("AcroExch.AVDoc")
If AVDoc.Open(FileIn, "") Then
Set PDDoc = AVDoc.GetPDDoc()
Set JSO = PDDoc.GetJSObject
x = PDDoc.GetNumPages
jso.print false, 1, x-1, true
gApp.CloseAllDocs
end if
next
gApp.hide : gApp.exit : Quit()
MsgBox "Done!"
Sub Quit
Set JSO = Nothing : Set PDDoc = Nothing : Set gApp =Nothing : Wscript.quit
End Sub
?cdate("2014/01/02 16:05:00") = dateadd("n",5,cdate("2014/01/02 16:00:00"))
False
?cdate("2014/01/02 16:05:00") - dateadd("n",5,cdate("2014/01/02 16:00:00"))
7.27595761418343E-12
DateDiff("s", cdate("2014/01/02 16:05:00"), dateadd("n",5,cdate("2014/01/02 16:00:00"))) = 0
#!/bin/sh
dirpath='/home/admin/mydb_dump/dump'
filename=`date +%Y%m%d`
mysqldump -uDB_USER -pDB_PASSWORD DB_NAME --ignore-table=mydb.table1 --ignore-table=mydb.table2 > $dirpath/mydb_$filename.dump
chmod 700 $dirpath/mydb_$filename.dump
tar cpzvf $dirpath/mydb_$filename.dump.tar.gz $dirpath/mydb_$filename.dump
rm -f $dirpath/mydb_$filename.dump
find $dirpath/mydb_????????.dump.tar.gz -type f -mtime +365 -ls -exec rm -f -- {} \;
chmod +x backup_mydb_db.sh
crontab -e
10 0 1 * * /home/admin/mydb_dump/backup_mydb.sh