WSHのプログラミングで、年月日(YYYYMMDD)や時間(HHMMSS)をとるのって、以外と手間だったりします。
ファイル名やタイムスタンプを表示するときに私は以下の関数を利用しています。
まずは、年月日からです。フラグで1以上の値を渡すと”YYYY/MM/DD”になり、0の場合は、”YYYYMMDD”になります。


Private Function Get_YYYYMMDD(ByVal STR_Flag)
  Dim STR_Temp
  Dim STR_YYYYMMDD

  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
  If STR_Flag >= 1 Then STR_Temp = STR_Temp & "/" End If
  STR_YYYYMMDD = STR_Temp

  STR_Temp = Month(Now())
  If Len(STR_Temp) = 1 Then STR_Temp = "0" & STR_Temp End If
  If STR_Flag >= 1 Then STR_Temp = STR_Temp & "/" End If
  STR_YYYYMMDD = STR_YYYYMMDD & STR_Temp

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

  GET_YYYYMMDD = STR_YYYYMMDD
End Function

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

14 Comments

  1. big fat com says:

    … [Trackback]

    […] Read More to that Topic: dragon-ark.com/archives/102 […]

  2. Supercritical CO2 Extraction Machine says:

    … [Trackback]

    […] Info on that Topic: dragon-ark.com/archives/102 […]

  3. kurumsal sunucu yapılandırma says:

    … [Trackback]

    […] Read More on that Topic: dragon-ark.com/archives/102 […]

  4. devops testing says:

    … [Trackback]

    […] Information to that Topic: dragon-ark.com/archives/102 […]

  5. Auto Glass marketing says:

    … [Trackback]

    […] Read More to that Topic: dragon-ark.com/archives/102 […]

  6. most expensive champagne brand says:

    … [Trackback]

    […] Read More here on that Topic: dragon-ark.com/archives/102 […]

  7. Darknet Marktplätze says:

    … [Trackback]

    […] Here you can find 20817 additional Information on that Topic: dragon-ark.com/archives/102 […]

  8. mens sport replica watches prices says:

    … [Trackback]

    […] There you will find 35674 more Info to that Topic: dragon-ark.com/archives/102 […]

  9. dispensary security says:

    … [Trackback]

    […] Read More here to that Topic: dragon-ark.com/archives/102 […]

  10. bloggerchest says:

    … [Trackback]

    […] There you can find 46635 additional Information on that Topic: dragon-ark.com/archives/102 […]

Leave a Reply