vb.net - Exclude weekends in delivery date -


i have code gets eta (estimated time of arrival) want exclude weekends. have change eta if past 2:30pm.

code:

    dim eta1 date = date.today.adddays(1)     dim eta2 date = date.today.adddays(2)     dim eta3 date = date.today.adddays(3)      dim day string = format(today, "dddd")     dim time date     dim currhour integer     dim currminute integer     time = datetime.now     currhour = time.hour     currminute = time.minute      if storebox.text "25*"         microlabel.visible = true          if currhour >= 2 andalso currminute >= 30             etabox.text = eta2         else             etabox.text = eta1         end if      else         microlabel.visible = false          if currhour >= 2 andalso currminute >= 30             etabox.text = eta2         else             etabox.text = eta1         end if      end if 

datetime flexible type allows perform many date/time related actions. don't need perform string-like analysis (what code doing).

for example, take care of 2 requested functionalities, like:

dim curtime datetime = dim goahead boolean = true  if curtime.dayofweek = dayofweek.saturday orelse curtime.dayofweek = dayofweek.sunday     goahead = false elseif curtime > new datetime(curtime.year, curtime.month, curtime.day, 14, 30, 0)     goahead = false end if  if goahead     'weekday before 2:30 pm end if 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -