Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simpler Datenum
#1
Code: (Select All)
a$ = Date$
month$ = Left$(Date$, 2)
day$ = Mid$(Date$, 4, 2)

Select Case month$
    Case "01": datenum = 0 ' jan 31
    Case "02": datenum = 31 ' feb 29+ F leap years
    Case "03": datenum = 60 ' mar 31+
    Case "04": datenum = 91 ' apr 30+
    Case "05": datenum = 121 ' may 31+
    Case "06": datenum = 152 ' jun 30+
    Case "07": datenum = 182 ' jul 31+
    Case "08": datenum = 213 ' aug 31+
    Case "09": datenum = 244 ' sep 30+
    Case "10": datenum = 274 ' oct 31+
    Case "11": datenum = 305 ' nov 30+
    Case "12": datenum = 335 ' dec 31+
End Select
datenum = datenum + Val(day$)
datenum$ = Right$("00" + _Trim$(Str$(datenum)), 3)

Print a$
Print month$
Print day$
Print datenum$
End

I wanted to simplify the code with a edit.  Messaged up the message big time.  So I deleted and retried.  If you remember my previous post.  You will notice the change after the end select and in each case. This will result in faster and smaller code, with no difference in performance.
Reply


Messages In This Thread
Simpler Datenum - by doppler - 05-04-2022, 04:43 PM
RE: Simpler Datenum - by Pete - 05-04-2022, 05:38 PM
RE: Simpler Datenum - by Pete - 05-04-2022, 07:10 PM
RE: Simpler Datenum - by dcromley - 05-05-2022, 04:49 AM
RE: Simpler Datenum - by Pete - 05-05-2022, 05:35 AM
RE: Simpler Datenum - by doppler - 05-05-2022, 02:10 PM
RE: Simpler Datenum - by Pete - 05-05-2022, 02:22 PM
RE: Simpler Datenum - by euklides - 05-07-2022, 07:59 AM
RE: Simpler Datenum - by doppler - 05-07-2022, 01:27 PM
RE: Simpler Datenum - by euklides - 05-08-2022, 11:59 AM



Users browsing this thread: 2 Guest(s)