Browsed by
Day: October 21, 2009

Returning the Nth weekday in SQL…and in InfoPath

Returning the Nth weekday in SQL…and in InfoPath

Ok, after much research I found a forum that had a posting that demonstrated how to get the Nth chosen weekday of a month using T-SQL. Here’s the code: DECLARE @date datetimeDECLARE @weekday intDECLARE @day datetimeDECLARE @number intDECLARE @WhichOne int SELECT @WhichOne = 2 — Set this to the week you want to grabSELECT @number = 1SELECT @weekday = 0SELECT @date = getDate() — Change to dateadd(month, 1, getDate()) for next month, etc. WHILE @weekday 4 — Change this value…

Read More Read More

Calculating Nth weekday of next month in Excel

Calculating Nth weekday of next month in Excel

I won’t normally post Excel stuff on here, but while researching an XSLT/Javascript function I was determined to get it right in Excel first, so I understood it better, and definitely wanted to document it so I could pull it back up later! In this example, I need to know the second Wednesday of next month, because that’s when server maintenance is every month. But what day is it? Here’s the Excel formula: =DATE(YEAR(TODAY()),MONTH(TODAY())+1,1+7*2)-WEEKDAY(DATE(YEAR(TODAY(),MONTH(TODAY())+1,8-4)) Notice the DAY argument of the…

Read More Read More

InfoPath data validation using regular expressions

InfoPath data validation using regular expressions

I found it interesting yesterday, while building an InfoPath template for SharePoint 2007, that you can use regular expression code to perform data validation the same way it’s used in an ASP.Net form, and the same way it’s done in C#. Here’s an example: In my form, I wanted to make sure the data entered conformed to a specific email address format. Normally, an email address pattern looks like this: w+([-+.’]w+)*@w+([-.]w+)*.w+([-.]w+)* This won’t work in InfoPath, there are too many…

Read More Read More