0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

<Python>業務ツール:直近の営業日の日付取得

Last updated at Posted at 2024-02-16

直近(当日を含めない)営業日を取得したい。
"YYYYMMDD"形式にてフォルダ名に取得して、フォルダ名に使用する。

日本の暦で営業する倉庫業者が、
出荷指示のCSVファイルを、翌営業日(YYYYMMDD)名のフォルダに格納するために作成。

import jpholiday
import datetime

date = datetime.date.today()
date = datetime.date(date.year, date.month, date.day + 1)

#土日・祝日確認用のブロック
while date.weekday() >= 5 or jpholiday.is_holiday(date):
    date = datetime.date(date.year, date.month, date.day + 1)

#フォルダ名用の形式
date = date.strftime("%Y%m%d")
print(date)

「出荷日_YYYYMMDDフォルダ」を作成する

import os
f = r"Path\出荷日_"+str(date)
os.makedirs(f)
0
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?