Friday, July 29, 2005

TSQL Date Teaser

Do you think you can solve the following problems using SQL Server TSQL ?

1) Given a date, find the date of the first day and last day of that week.
E.G: Given 28-July-2005, You have to tell 24-July-2005 is the first day
of that week and 30-July-2005 is that last day of that week.

2) Given a date, find the date of the first day and last day of the month.
E.G: Given 21-July-2005, You have to tell 1-July-2005 is the first day of
the month and 31-July-2005 is the last day of the month.

3). Given a date, find the last Friday of the month.
E.G: Given 10-July-2005, last Friday for the month is 29-July-2005.

4) A slight variation from (3), given a date, find the second last Thursday
of the month.
E.G: Given 10-July-2005, second last Thursday of the month is 21-July-2005.

Your solution must also be able to find (N)th last (day of the week) of the month.
Where : N can be last week, second last week, third last week and so on,
day of week can be any day from Sunday to Saturday.


5). Given a date, find the first Tuesday of the month.
E.G: Given 10-July-2005, first Tuesday for the month is 5-July-2005.

6) A slight variation from (5), given a date, find the second Thursday
of the month.
E.G: Given 10-July-2005, second Thursday of the month is 14-July-2005.

Your solution must also be able to find (N)th (day of the week) of the month.
Where : N can be first week, second week and so on.
day of week can be any day from Sunday to Saturday.

Condition :
1) You can only use TSQL Date and Time function.
2) Only simple expressions are allowed. (EG : add, minus, multiply, divide, assignment, variables).
3) Language element such as Loop, if..else, case statement are not allowed.
4) Assume first day of the week is Sunday and last day of the week is Saturday(which is default in most
SQL Server installation).
5) You can't deal with leap year explicitly. Meaning, you cannot write your own algorithm to check
for leap years. You are only allowed to use TSQL DateTime function.

Try it and I will post the solutions by the next 2 weeks.

Labels:

Wednesday, July 20, 2005

Improving performance of the web part page gallery

If you find it can sometimes take 20 to 30 seconds to return the web part gallery so that you can drop a web part onto a web part page then this post is for you.

The problem may be because SharePoint is trying to contact the online web part gallery, however, if your machine is not connected to the internet, or the proxy is not configured properly, then it could take some time to actually work this out. This is the delay you are seeing.

You can easily turn off the web part gallery by following these simple steps:

1. Open SharePoint Central Administration (make sure you are on the Windows SharePoint Services page)

2. Click on "Configure Virtual Server"

3. Select the Virtual Server on which you are experiencing the delay

4. Click "Manage Security Settings for Web Part Pages"

5. Select the "Disabled" option next to "Online Web Part Gallery" and click OK.

Labels:

Monday, July 18, 2005

2 pair of shoes && 1pair of sandals.

What a year it is! This year alone I have wear off 2 pair of shoes and 1 pair of sandals.

I broke my first pair of shoe when I was in Hong Kong couple of months ago.
The second pair wore off yesterday while I was tracking in a forest reserve.
And my sandals is just a "natural die-off".

Perhaps it is time for a change.

Sunday, July 10, 2005

Floating box using CSS layout


How do you create a floating box which is attached to a particular corner of a layout container like this :




This is in a box.

I'm sitting in a hotel room in San Francisco working on a project that can't wait until I get back to my office, and all I can think about is my reliance on connectivity. I, and a bunch of other happy developers, am here because of the VSLive/VBits conference. Trouble is, I didn't bring everything I need for my work, so now I desperately need a network connection. Sure, I have dial-up access in the hotel room, but though quick enough for e-mail, it's anything but practical for large file transfers.


Sound like a familiar situation? Well, it happens to me all the time, and usually it's a pain. This time, however, I decided I'm not going to be beaten by mere, piddling circumstances. I am, after all, a developer. Not only that, I'm a developer looking for a good time (developing that is). I'm going to solve this problem—and turn the solution into this month's article.


Okay. So let's say there is a file that I need and I can't wait until I'm back in Redmond. For instance, let's say it is the demo for Impossible Creatures (which is a whopping 285 MB), and that I really, really need it for some serious research. As I said, my dial-up access is slower than a dead snail, but there is wireless in a nearby coffee shop that should be considerably faster.



The key is to use the CSS float attribute.

For example to create the above layout, use the following css style and sample:


<style type="text/css">

#main
{
border:1px solid #000;
background:#ffffff;
}

#main #floatbox {
background: #dddddd;
float: left;
width: 230px;
height : 50px;
border: #ff0000 1px solid;
}
</style>


<div id="main">
<div id="floatbox">
This is in a box.
</div>
I'm sitting in a hotel room in San Francisco working on a project that can't wait until I get back to my office, and all I can think about is my reliance on connectivity. I, and a bunch of other happy developers, am here because of the VSLive/VBits conference. Trouble is, I didn't bring everything I need for my work, so now I desperately need a network connection. Sure, I have dial-up access in the hotel room, but though quick enough for e-mail, it's anything but practical for large file transfers.
<p>
Sound like a familiar situation? Well, it happens to me all the time, and usually it's a pain. This time, however, I decided I'm not going to be beaten by mere, piddling circumstances. I am, after all, a developer. Not only that, I'm a developer looking for a good time (developing that is). I'm going to solve this problem—and turn the solution into this month's article.
<p>
Okay. So let's say there is a file that I need and I can't wait until I'm back in Redmond. For instance, let's say it is the demo for Impossible Creatures (which is a whopping 285 MB), and that I really, really need it for some serious research. As I said, my dial-up access is slower than a dead snail, but there is wireless in a nearby coffee shop that should be considerably faster.
</div>

Labels:

Monday, July 04, 2005

Notepad Replacement

I have been using other text editors as notepad replacement for quite some time. I
highly recommend the following 2 editors (all free):

Notepad2

Notepad++


Both support features like :
-Line number display.
-Syntax Highlighting.
-Bookmark.
-Zooming.
-Show White Space and Line End character.
-Small in size. Put into your PenDrive and you are good to go.
-Does not require installation. Unzip the file and you are ready to rock and roll.
-and many more.


There subtle difference between the two is :
Notepad2 :
-SDI interface.
-Consume less memory.

Notepad++ :
-MDI interface.
-Consume more memory than Notepad2.