Powered by GeSHi

Source code for tomorrow.vbs

(view source code of tomorrow.vbs as plain text)

  1. ' Tomorrow.vbs,  Version 1.00 for Windows Script Host 2.00
  2. ' Display today's, yesterday's and tomorrow's date in two formats
  3. '
  4. ' Written by Rob van der Woude
  5. ' http://www.robvanderwoude.com
  6.  
  7. ' Specify header
  8. strHead    = "Format:     YYYYMMDD  (DD/MM/YYYY)" & vbCrLf _
  9.            & "==================================" & vbCrLf
  10.  
  11.  
  12. ' Get current year
  13. strYear = DatePart("yyyy",Date)
  14.  
  15. ' Get current month, add leading zero if necessary
  16. If DatePart("m",Date) < 10 Then
  17. 	strMonth = 0 & DatePart("m",Date)
  18. Else
  19. 	strMonth = DatePart("m",Date)
  20. End If
  21.  
  22. ' Get current day, add leading zero if necessary
  23. If DatePart("d",Date) < 10 Then
  24. 	strDay = 0 & DatePart("d",Date)
  25. Else
  26. 	strDay = DatePart("d",Date)
  27. End If
  28.  
  29. ' Format output for today
  30. strToday = "Today:      " & strYear & strMonth & strDay _
  31.          & "  (" & strDay & "/" & strMonth & "/" & strYear & ")" & vbCrLf
  32.  
  33. ' Calculate yesterday's date
  34. dtmYesterday = DateAdd("d",-1,Date)
  35.  
  36. ' Get yesterday's year
  37. strYear = DatePart("yyyy",dtmYesterday)
  38.  
  39. ' Get yesterday's month, add leading zero if necessary
  40. If DatePart("m",dtmYesterday) < 10 Then
  41. 	strMonth = 0 & DatePart("m",dtmYesterday)
  42. Else
  43. 	strMonth = DatePart("m",dtmYesterday)
  44. End If
  45.  
  46. ' Get yesterday's day, add leading zero if necessary
  47. If DatePart("d",dtmYesterday) < 10 Then
  48. 	strDay = DatePart("d",dtmYesterday)
  49. Else
  50. 	strDay = DatePart("d",dtmYesterday)
  51. End If
  52.  
  53. ' Format output for yesterday
  54. strYest = "Yesterday:  " & strYear & strMonth & strDay _
  55.         & "  (" & strDay & "/" & strMonth & "/" & strYear & ")" & vbCrLf
  56.  
  57. ' Calculate tomorrow's date
  58. dtmTomorrow = DateAdd("d",1,Date)
  59.  
  60. ' Get tomorrow's year
  61. strYear = DatePart("yyyy",dtmTomorrow)
  62.  
  63. ' Get tomorrow's month, add leading zero if necessary
  64. If DatePart("m",dtmTomorrow) < 10 Then
  65. 	strMonth = 0 & DatePart("m",dtmTomorrow)
  66. Else
  67. 	strMonth = DatePart("m",dtmTomorrow)
  68. End If
  69.  
  70. ' Get tomorrow's day, add leading zero if necessary
  71. If DatePart("d",dtmTomorrow) < 10 Then
  72. 	strDay = 0 & DatePart("d",dtmTomorrow)
  73. Else
  74. 	strDay = DatePart("d",dtmTomorrow)
  75. End If
  76.  
  77. ' Format output for tomorrow
  78. strTomor = "Tomorrow:   " & strYear & strMonth & strDay & "  (" & _
  79.           strDay & "/" & strMonth & "/" & strYear & ")"
  80.  
  81. ' Display the result
  82. Wscript.Echo( strHead & strYest & strToday & strTomor )
  83.