update: end goal:
show may 10th - june 8th, dates in between prefix may or june (month name). ever date today.. border around calendar day (style stuff) outputs dates in between, each day 'date' in today highlighted. outputs calendar, various (unique images) per calendar day (in between described date range). add specific styles calendar day 'today'. if it's 11th, specific styles may 11th visible in calendar region -- if june 2nd same.
i can within 1 month / same month; below, it's not simple, because date range in between 2 months. may 10th - june 8th. how can split 2 arrays - , it's not date range; need detect if day today.
<% = 10 31 dim time if < day_part time = "past" elseif = day_part time = "today" else time = "future" end if suffix = suffixer(i) response.write("<section id='day_"& &"' class='calsquare " & time &"'><article class='dateimage' style='background-image: url(images/calendar_thumbnails/day_"&i&".jpg)'></article></article><article class='datetitle'> "&i&suffix&"</article></section>") next <!--response.write(products(0))--> %>
latest code via answered suggestion below (others have reviewed may not valid vbscript suggestion got):
<% dim d1 new date(2015, 5, 10) dim d2 new date(2015, 6, 8) dim daysbetween long = datediff(dateinterval.day, d1, d2) dim d3 date d long = 0 daysbetween d3 = d1.adddays(d) if d3 < today() elseif d3 = today else end if dim suffix string = suffixer(d3.day) next response.write("<section id='day_"& d &"' class='calsquare " & time &"'><article class='dateimage' style='background-image: url(images/calendar_thumbnails/day_"&d&".jpg)'></article></article><article class='datetitle'> "&d&suffix&"</article></section>") <!--response.write(products(0))--> %>
*i have replaced i d across board (with above attempt) -- , didn't work! have updated question latest code well. i've gotten feedback logic correct may not valid vbscript constructs being used. other suggestions amazing!*
fnostro's
rule #27: don't use integers when mean dates
is correct, answer violates
rule #1: use vbscript
so if need answer coool's question (and solution formatting problems in vbscript (cf. here):
option explicit ' !! http://csharphelper.com/blog/2014/11/convert-an-integer-into-an-ordinal-in-c/ ' return int's ordinal extension. function ordext(value) ' start common extension. ordext = "th" ' examine last 2 digits. dim last_digits : last_digits = value mod 100 ' if last digits 11, 12, or 13, use th. otherwise: if last_digits < 11 or last_digits > 13 ' check last digit. select case last_digits mod 10 case 1 ordext = "st" case 2 ordext = "nd" case 3: ordext = "rd" end select end if end function ' !! https://stackoverflow.com/a/11262441/603855 class cformat private m_osb private sub class_initialize() set m_osb = createobject("system.text.stringbuilder") end sub ' class_initialize public function formatone(sfmt, velm) m_osb.appendformat sfmt, velm formatone = m_osb.tostring() m_osb.length = 0 end function ' formatone public function formatarray(sfmt, aelms) m_osb.appendformat_4 sfmt, (aelms) formatarray = m_osb.tostring() m_osb.length = 0 end function ' formatarray end class ' cformat dim of : set of = new cformat dim sfmt : sfmt = "<section id='day_{0}' class='calsquare {1}'><article class='dateimage' style='background-image: url(images/calendar_thumbnails/{2}/day_{0}.jpg)'></article></article><article class='datetitle'>{2} {0}{3}</article></section>" dim dtoday : dtoday = #3/1/2012# ' fake needed feb 29th demo dim atime : atime = split("past today future") dim d d = #2/27/2012# #3/4/2012# wscript.echo d, typename(d), atime(sgn(datediff("d", dtoday, d)) + 1) wscript.echo of.formatarray(sfmt, array(day(d), atime(sgn(datediff("d", dtoday, d)) + 1), monthname(month(d)), ordext(day(d)))) next
output:
cscript 29906416.vbs 27.02.2012 date past <section id='day_27' class='calsquare past'><article class='dateimage' style='background-image: url(images/cal endar_thumbnails/february/day_27.jpg)'></article></article><article class='datetitle'>february 27th</article>< /section> 28.02.2012 date past <section id='day_28' class='calsquare past'><article class='dateimage' style='background-image: url(images/cal endar_thumbnails/february/day_28.jpg)'></article></article><article class='datetitle'>february 28th</article>< /section> 29.02.2012 date past <section id='day_29' class='calsquare past'><article class='dateimage' style='background-image: url(images/cal endar_thumbnails/february/day_29.jpg)'></article></article><article class='datetitle'>february 29th</article>< /section> 01.03.2012 date today <section id='day_1' class='calsquare today'><article class='dateimage' style='background-image: url(images/cal endar_thumbnails/march/day_1.jpg)'></article></article><article class='datetitle'>march 1st</article></section > 02.03.2012 date future <section id='day_2' class='calsquare future'><article class='dateimage' style='background-image: url(images/ca lendar_thumbnails/march/day_2.jpg)'></article></article><article class='datetitle'>march 2nd</article></sectio n> 03.03.2012 date future <section id='day_3' class='calsquare future'><article class='dateimage' style='background-image: url(images/ca lendar_thumbnails/march/day_3.jpg)'></article></article><article class='datetitle'>march 3rd</article></sectio n> 04.03.2012 date future <section id='day_4' class='calsquare future'><article class='dateimage' style='background-image: url(images/ca lendar_thumbnails/march/day_4.jpg)'></article></article><article class='datetitle'>march 4th</article></sectio n>