【WSH】昨日の日付を表示する

このエントリーをはてなブックマークに追加
Bookmark this on Livedoor Clip

昨日の日付を表示するVBスクリプトです。

現在の日付を求めるために別の関数を呼んでいます。


Option Explicit

  Dim STR_Yesterday
  Dim STR_Temp

  STR_Temp = Get_YYYYMMDD(1)
  STR_Yesterday = DateAdd("d",-1,STR_Temp)

  WScript.Echo STR_Yesterday
Private Function Get_YYYYMMDD(ByVal STR_Flag)
  Dim STR_Temp
  Dim STR_YYYY
  Dim STR_MM
  Dim STR_DD

  If Not IsNumeric(STR_Flag) Then Exit Function End If

  STR_Temp = Year(Now)
  If Len(STR_Temp) = 2 Then STR_Temp = "20" & STR_Temp End If
  STR_YYYY = STR_Temp

  STR_Temp = Month(Now())
  If Len(STR_Temp) = 1 Then STR_Temp = "0" & STR_Temp End If
  STR_MM = STR_Temp

  STR_Temp = Day(Now())
  If Len(STR_Temp) = 1 Then STR_Temp = "0" & STR_Temp End If
  STR_DD = STR_Temp

  Select Case STR_Flag

    Case 0

      GET_YYYYMMDD = STR_YYYY & STR_MM & STR_DD

    Case 1

      GET_YYYYMMDD = STR_YYYY & "/" &  STR_MM & "/" & STR_DD    

    Case 2

      GET_YYYYMMDD = "#" & STR_DD & "/" & STR_MM & "/" & STR_YYYY & "#"

  End Select

End Function

Scriptのダウンロードは こちら です。

VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)
This entry was posted in WSH.

コメントを残す

メールアドレスが公開されることはありません。

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

1 / 11