4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Uipathで業務上よく使う日付の取得(年度の取得/対象曜日の日付取得/月末日の取得)

Posted at

年度の取得

対象の日付から月から-3か月した時の年が年度になります。
 取得年度 = 対象日.AddMonths(-3).Year
image.png

対象曜日の日付取得

DayOfWeekを活用することで、曜日から日付を取得することが可能です。
今週月曜.AddDays( DayOfWeek.Monday – 今日日付.dayofweek )
求めたい曜日によって、Mondayの部分を変更してください

  • 月→Monday
  • 火→Tuesday
  • 水→Wednesday
  • 木→Thursday
  • 金→Friday
  • 土→Saturday
  • 日→Sunday
    image.png
    DayOfWeekで日付がなぜ取得できるのかの詳細はMicrosoft公式リファレンスを確認してください

月初日,月末日の取得

DaysinMonthを使用することで月末日の取得が可能です。
DateTime.DaysinMonth(年,月).ToString
image.png
日付形式で出力されるわけではなく下記スクリーンショットのように、日付だけで出力されるので、注意が必要です。
image.png

4
0
0

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
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?