Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

How Can I Subtract a Specified Number of Days from a UTC Value?

(image) Hey, Scripting Guy! Suppose I get a date-time value in UTC format. How can I subtract x number of days from that value?-- MW(image) (image) (image) Hey, MW. First of all, we’d like to thank you for your question; in addition, we’d like to welcome you and everyone else to today’s Open House in honor of the 500th Hey, Scripting...

How Can I Determine Which Day of the Year a Date Falls On?

(image) Hey, Scripting Guy! How can I determine which day of the year a date falls on? For example, March 2, 2006 is the 61st day of the year.-- TW(image) (image) (image) Hey, TW. You know, we almost feel guilty about answering this question. Why? Well, after all, we can answer it by writing just one line of code:Wscript.Echo DatePart("y...

How Can I Determine the Beginning and Ending Date of the Previous Month?

(image) Hey, Scripting Guy! Given a specific date, how can I determine the beginning and ending date of the previous month? In other words, given 8/11/2005, I need to get back 7/1/2005 and 7/31/2005.-- PH(image) (image) (image) Hey, PH. You know, this was a tough question for us: after all, as Microsoft employees we’re always looking ...

How Can I Tell if a Date Falls within a Specified Time Period?

(image) Hey, Scripting Guy! How can I tell if a date falls within a specified time period?-- JW(image) (image) (image) Hey, JW. By amazing coincidence on our way to work this morning we heard two different commercials, from two different companies, touting “Christmas in July.” That prompted us to answer your question as soon as we got ...