Finding A Week in T-SQL :: Tip o' The Day

Recently I needed to identify a week within a T-SQL Query.  First off I figured I would want to know what day it is, then I could easily figure out a week time frame.

To verify what day you have selected, use the following code:

IF DATENAME(weekday, ‘1/7/07’) = ‘Sunday’ BEGIN     SELECT ‘Sunday’ END ELSE     SELECT ‘Not Sunday’

I created this check to verify that someone had entered the beginning of the week they wanted properly.  If it isn’t Sunday, they won’t get a proper week.  The key function above is the DATENAME.

Once I have the first day of the week figuring out the date range for the week is super easy.  I made a few modifications and added a select statement to print out the start and end date of the date range.

DECLARE @StartDate smalldatetime DECLARE @EndDate smalldatetime

SET @StartDate = ‘1/7/07’

IF DATENAME(weekday, ‘1/7/07’) = ‘Sunday’ BEGIN     SET @EndDate = DATEADD(day, 7, @StartDate) END ELSE     SELECT ‘Not Sunday’

SELECT @StartDate AS ‘Start Date’, @EndDate AS ‘End Date’

I’m working on some other things for this particular date calculating type of need, and will write up an entry based on that too.  One of the things I think would be a great addition to this function is to be able to enter any date and have the SQL give a week date range in return based on the closest week starting date.

CodePlex Time

Over the weekend I made several attempts to download the BlogEngine on CodePlex by Mads Kristenson several times.  The problem, was that the site kept timing out.  I’m not sure if the local Comcast Service was having another issue or if the site was really down, but either way I wasn’t able to pull it up.  Fortunately that wasn’t such a big deal, because I had to spend my weekend reloading Windows Vista because… well, read the previous entry.

So anyway, with the monstrosity that upgrading Community Server to the latest version has become, I’ve started thinking about engines what are easier to maintain and provide more pointed functionality.  Community Server is ok, but the version I am running is 2.1, which is really outdated.  I’ve been looking at the latest version but between review of the database schema, the code base, and being unsure of what exactly they’re doing or attempting to do for a technology path I will probably move to a different product.  So far the BlogEngine seems like the best choice.

My main research right now centers around a way to export my blog entries from Community Server to the BlogEngine database.  I’ll probably create an SSIS Package to handle the export and import, as I’ll finish that and still be posting, which means I’ll need to do a final export on the last day of usage.  For the next 2 weeks I’m still crunching at work on T-SQL & getting some WebTrends Application specific work, at home I’m crunching on another project, and now I have this.  All together I’m going to be slammed!  At some point I’m hoping to have free time to go out and eat dinner or relax sometime.

…hey, a guy can dream!  Stick out tongue [:P]

Word Posts, Vista Reload, and General Maintenance

I sat down Friday afternoon to unwind and play a little Supreme Command. Instead of being able to play, some program that came on my machine with the original load started working away. Of course this action was without my permission. It created a very choppy effect and the mouse would barely work. Shifting from the game to windows I found that in addition to the McAfee Virus Scanner kicking in another two applications were accessing the hard drive. Not something one wants to occur when you have a laptop hard drive. With all this I decided it was time to just get rid of this factory load and get a fresh load of Windows Vista on this machine. At least then I would know if it actually performed or not on this particular machine.

After a 35 minute troubleshooting session with Dell Tech Support to find out that the default AHCI setting for the hard drive needed to be changed to ATA or Vista would blue screen, I got it loaded. This was of course after about 3 hours of me troubleshooting the blasted machine. I really love scenarios like that were there is no logical or reasonable way to troubleshoot something because there is no access to any log or exception (the blue screen literally would flash with no way to pause it). But now that I have the machine loaded I’ve been cruising along at a good pace loading software and working on some things. I got Visual Studio 2008 reloaded on my primary host machine, which will be nice since that is where all of my new development will be taking place. Hopefully I’ll get all my standard settings and software loaded by the end of this coming week; it really sucks to have a machine that is limping along.

On another note, I seriously wonder what Microsoft intends to do about Vista. I’m sure eventually people will start moving to it, but most are getting burned pretty badly. I’m sure it has started to cause a trickling, if not an outright flow, of PC users to Mac. I can’t blame any of them; I’m seriously back at wondering if I shouldn’t go buy a Mac to work on my afterhours work. Simply put, Vista is not ready for prime time, and after closer inspection and understanding of the situation, neither is today’s hardware. We need 64 bit across the board with 4-8 GB of RAM for Vista to really be impressive. We’ll get there, but it isn’t going to happen tomorrow. I’d be surprised if we get there by end of 2008.

In addition to getting Visual Studio 2008 loaded back on my machine, I also loaded Office Ultimate 2007. Since Word 2007 has blog posting features I’m going to give it a try over Windows Live Writer to see how it is different or better (or worse). This entry will be my first posting with it.

So the weekend is pretty much over, it ended up being a general maintenance weekend instead of build new apps and writes more code weekend. That is a problem, but sometimes, one has to start on a fresh canvas to get the art created.

Mr. Guthrie Rolls The .NET Road Map

I’m not even going to write much on this road map topic, I’m just looking forward to the ASP.NET MVC.  In almost every application I have lined up, even a lot of the prospective business intelligence work I have lined up this pattern architecture will be ridiculously useful!  Separation of concerns is of vital importance in so many aspects.

I’m all about being organized and neat in my code, to the point of a slight obsession.  The fact that the MVC enables a lot of this is absolutely great.  However I have to agree with Andy Wardley that MVC is not particularly the magic bullet that is going to give us a “100% clear” separation of concerns, but does guarantee us a separation.  There are however other segments and pieces that could or even do demand a separation.  The MVC is kind of a start.  What I have seen from the examples present by Hanselmen, Guthrie, and the other crew on the team the MVC they are producing will be one of the, if not the coolest MVC out.

Being that I have a year under my belt of the monstrosity that CAB and the SCSF attempted to piece together, I’m all that much more exited about their implementation.  I reviewed my entries from over a year ago, they’re rather crappy and not very informative, I’ll definitely have to provide some new entries with a solid set of examples for the new MVC.

With that, I’m signing off for the day, off to another geek meet and hopefully some cool Silverlight work tonight!

How to Be Heard?

In almost every business, even when there are only two participants, there is always a need to communicate.  The emphasis of teaching others to speak well, write well, and in general communicate their point clearly and decisively is very important.  I however have found that one soft skill that is just as much, if not more important, is making sure that whoever you are communicating to is hearing what you are saying.

All to often in work environments people communicate the entire day with a mere percentage of that being effective.  The problem is not always clear and decisive communication but getting and knowing when someone is hearing and understanding you.

In the technology field that is multitudes more important, everything is loaded with context, and even a slightly wrong assumption, or notion will land a task or effort at risk of being completed properly.  In the technology industry doing something improperly is often as bad or worse than just not doing it at all.

I just happened recently to start thinking about some past companies I have worked at and realized that one of my strong points is communicating, however I have a weak point inside the strong point.  I don’t always get, or even know how to get people to listen and hear me.  I’ve told people things that are of immense importance to be brushed aside, only to state, “I told you so” a few months later.  Now don’t get me wrong, I enjoy the I told you so statements, but I’d rather just be heard and be able to have effective communication and efforts done right the first time.

In the business intelligence community this need exists and is expanded to more disparate persons.  Often executives are asking for things directly to the actual geeks (the BI people).  Fortunately, and maybe I shouldn’t admit it openly, BI is a pretty easy toolset and skill to learn.  Often the hardest part to grasp is that there isn’t that much to grasp.

I’ve found that the hardest part is getting clear cut instructions on what end users (executives and managers) really and truthfully want.  In addition to that it is often unclear what they even want to derive from the data they are going to get.

Now after all that said I pose a question and pondering.  What other things, what other sources are out there, to help improve the soft skill of noticing and assuring people are hearing and understanding what is really being communicated?