NEWS AND RSS

Select a source:
SQL Server 2005: Date Only

In the business world, many reports are date and time sensitive. At times, all that matters is the date or the number of days difference from the current point and time.

This frequently creates the situation where the time portion of the datetime field type does not need and should not examine the time portion of this data type. When running a comparison in SQL Server 2005 for example, June 23rd at 1:00 A.M. is not the same as June 23rd at 12:00 A.M.

Therefore, it becomes necessary to compare the date portion of this type.

The official SQL Server Books online documentation states regarding the datetime type: "The first 4 bytes store the number of days before or after the base date: January 1, 1900."

Note the following examples executed in Query Analyzer application:

select convert(datetime, 39988) 
- output: 2009-06-26 00:00:00.000

select convert(datetime, 39988.5) 
- output:2009-06-26 12:00:00.000

select convert(datetime, 39988 + 14) 
- output:2009-07-10 00:00:00.000

select floor(convert(numeric(18,9),getdate())) 
- output:39985

select convert(datetime, floor(convert(numeric(18,9), getdate() + 14))) 
- output: 2009-07-07 00:00:00.000

The first example shows that a whole number produces a date and time that is 39988 days beyond January 1, 1900. It also shows that a whole number produces no time element in the datetime evaluation.

The second example show that providing a partial number (in this case 1/2) moves the hours to the time elapsed during the day (0.5 = 12 hours).

The third example shows adding 14 days to the previous input.

The fourth example shows getting the current system date and truncating the decimal portion.

The fifth example shows adding 14 days to the current date, truncating the time/decimal portion and then converting the numeric result back to the datetime type.

One consideration for these snippets is to create a SQL Server function that abstracts the conversion process.


Click to read more.
Determination Rock

April 11, 2009 - Determination Rock is just located off of Mill Canyon Road just a bit north of Moab, Utah. There are a few good family options nearby. There are even fossilized dinosaur bones that can be plainly seen just a bit off route. There are plenty of signs to get to the main destinations. However, there are fewer signs to get to Determination Rock.

We took three jeeps on this short course to get to the rock. There was one point where the wash that is travelled to get to the rock had some potential tire hazards. It is a good idea to have a spotter in this area. From the state road, it is a short journey. Near the end of the journey, there is a minor climb on the slick rock which still may need to be spotted for novice drivers.

It is a pleasant place to have a lunch. Our group spent well over an hour there. There was a geocache site nearby.

Be wary of bicyclists who take both sides of the road and don't like to share. They may signal you their displeasure if you don't let them have both sides of the road.

On the other side of the state road, there are some nice washes perfect for running your jeep.


Click to read more.
Delicate Arch

The beautiful arch that you see pictured at the top of each page on this web site is the world-famous delicate arch. It is located in Arches National Park just outside of Moab. On the way to the arch and as we were travelling through the park, there was big horn sheep right next to a warning sign that says there may be big horn sheep around.

After a few minutes journey, park visitors see the Balanced Rock. A bit beyond that, is the trailhead to Delicate Arch. For park users that do not wish to hike, there is a nearby lookout to which they can drive. We chose to take all the children on the hike. Even with the young children, the hike only took about one hour. We stayed there for an hour. There were plenty of hikers from all types of nationalities and origins enjoying this natural wonder.


Click to read more.
Around Town

April 9, 2009 - Moab has several parks. One is located at 100 West and 400 North. It isn't far off the main street. A few of us went to the park for a few hours. The five-year old, three-year old and infant were all in their delight. The park had plenty of good playground equipment for those age groups. On one end of the park, there is a skateboard park and a covered stage. Centered in the park is the playground equipment. There is plenty of open space for other activities.

Adjacent to the park is a community swim center. It didn't seem to be the typical center; It had several adults doing laps.

After lunch, we visited the rock shop that is near the edge of Moab. There were all sorts of interesting rocks. The three-year old picked up several rocks including some that were quite valuable. He was instructed to put one back, so from about ten feet away, he found the right pile where he got it from and threw the rock back into its proper pile. We learned at the store that there is an area beyond Potash (about 20 miles from Moab) where many of the store's collectables are picked up.

We journeyed out this way before it started to get dark. On the way, there are dinosaur prints that can be examined from the road along the Colorado River. The prints are high up on a vertical slab of rock. They are white on a dark slab so they are quite visible. By the time, we hit the end of the road beyond Potash, we had to turn back because the road was bad and it was getting dark.


Click to read more.
In The ‘Hood

April 9, 2009 - Nearby in a field where we are staying in the Moab neighborhoods, there is a flock of wild turkeys. A few of us (2 adults, 2 children) went to get up close.

As we approached the turkeys, we called out in turkey language hoping for a response. However, they slowly moved away from us as we approached and found their way into the brush.

However, the journey was not without merit. The children were able to see what turkey tracks look like. They also seen the fresh droppings. Nearby where the turkeys had retreated into the brush, we found a deer skeleton and bones.


Click to read more.
Journey to Moab

April 8, 2009 - From Ogden, Utah to Moab, Utah, the journey takes a total of about 4 1/2 hours for a total of about 270 miles. Leaving in the afternoon, we made our way down Interstate 15 until Spanish Fork. We made one stop in Spanish Fork.

After the break, we took State Road 6 towards Price, Utah. We tuned the radio to listen to the Utah Jazz basketball game, but lost reception about five miles into the Spanish Fork Canyon. Just before we hit Price, we had seen the coal power plant all lit up at night and it's quite a sight also in respect to the coal miners that lost their lives in that area recently. The lights from plant are brilliant considering the dullness of the terrain on the way there. We made one stop in Price just before hitting Wellington. There were plenty of choices for gas and refreshment in this area.

Once we had hit Price, we discovered that we could find the basketball game on the radio again, but it was being broadcast from a station in Helper or Price. As we journeyed towards Green River, Utah, we found all sorts of radio stations. For a brief moment, we seemed to have found a station that was playing native american music. We also found plenty of stations that were playing 80s and 90s contemporary music. There's one country station that we could pick up and the advertisements on the station definitely had a local flavor.

As we made it to the Green River area, we hopped onto to Interstate 70. There are parts of the road that seemed a bit rough and hardly graded. For a moment, we thought something was wrong with the car, but needless to say, that the road is rough by design. The road signs warn of the strips to keep drivers awake. To get to Moab, we needed to turn south on Crescent Junction. This road takes you to Moab, Arches National Park and Canyonlands National Park. This road is especially bumpy with little gullies. Who knows what it would do to your low rider?


Click to read more.
Example: CSS Floating Layout

For years, web developers have used the <table> tag to control page formatting. Even tools like Adobe Dreamweaver has templates that make extensive use of the <table> tag for this purpose. However, the <table> tag was intended for displaying tabular data.

CSS 2.1 gives the web developer great control over the format of the page. Although all the major browsers have slightly different implementations, there are few glaring differences.

Click here to learn more.


Click to read more.
Gotcha CAPTCHA

"CAPTCHA is a type of challenge-response test used in computing to determine that the user is not run by a computer." Many services on the web use a CAPTCHA test to determine if the a user is legitimate. A common test is to show a distorted image and then the user will respond by typing the text of the distorted letters.

The security labs at websense.com did some interesting work how the CAPTCHA test for Live Mail (a Microsoft e-mail service) is being subverted (link: http://securitylabs.websense.com/content/Blogs/3063.aspx). The article shows how a "victim" computer is used to create the accounts. This is all the more reason that users should be wary and take security of their own computer seriously.


Click to read more.
Code Snippet: T-SQL Paging

Although there is already some infrastructure for paging in many development tools, sometimes a custom solution is needed.

Here's a T-SQL example of how to create your own paging data within your query. In this example, I have aggregated four additional columns. Replace 'sys.sysobjects' with the table that you wish to query. Replace 'sys.sysobjects.[name]' with the column list that you would like to use to order the query results. The @pagesize variable can be modified to set the page size.

declare @resultcount int
set @resultcount = (select count(*) from sys.sysobjects)

declare @pagesize int
set @pagesize = 10

SELECT
    row_number() over (order by sys.sysobjects.[name]) as 'ResultCount',
    convert(int, (row_number() over (order by sys.sysobjects.[name]) - 1) / @pagesize) + 1 as 'CurrentPage',
    convert(int, @resultcount / @pagesize + 1) as 'MaxPages',
    @resultcount as 'MaxResult',
    sys.sysobjects.*
FROM
    sys.sysobjects


Click to read more.
ASP .Net Themes Simplicity

ASP .Net themes are simple to implement. Themes permit the developer to dynamically show different images and use different stylesheets based on a user preference. Using Visual Studio 2008, it doesn't take long to get a web site project running and using themes. To get the full details, click here.


Click to read more.