How to Floor an SQL DateTime

July 3, 2008 14:10 by thebeebs

 

If you call GetDate you get todays date and time but what if you just want the date and not the time.

SQL provides no simple mechanism to do this but the solution below is probably the best way I’ve found:

CAST(FLOOR( CAST( GETDATE() AS FLOAT ) )AS DATETIME)

 

So a full example would be:

DECLARE @CurrentDate Datetime 
SET @CurrentDate = GETDATE() 
DECLARE @CurrentDateFloor Datetime 

SET @CurrentDateFloor  = CAST(FLOOR( CAST( GETDATE() AS FLOAT ) )AS DATETIME) 

SELECT @CurrentDateFloor  

2007–30-07 12:12:45 becomes 2007-30-07 00:00:00


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories:
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Chris Madden

June 19, 2008 22:01 by thebeebs

I was wondering around myspace and saw this video of my friend Chris Madden. I'm not sure if you'll find it funny but I certainly did.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories:
Actions: E-mail | Permalink | Comments (1) | Comment RSSRSS comment feed

Buying Books

May 31, 2008 16:29 by thebeebs

A friend of mine told me as story which made me laugh, his girlfriend asked for a book for her birthday. She told him the title and explained that she'd saw it on Richard and Judy. He went out and bought the book Men Are from Mars, Women Are from Venus turns out that the book he bought was ironic since she actually asked for Why Men Don't Listen And Women Can't Read Maps


Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories:
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

PHP Ain't so bad

May 30, 2008 15:51 by thebeebs

Who would have thought it. Last night I booted up my computer, opened up notepad and got to work on a quick fix for a PHP website. For the people out there who have no idea what PHP is, it's just another Web development Language that rivals my main language Asp.Net.

I've hardly ever used PHP because it's always felt like a step back in time, it's structured very much like an old language I used before called ASP, and the headaches I used to have managing large site, with lots of source and includes wasn't something I fancied subjecting myself to again.

As I was ploughing through the code I started thinking, this is so easy, this is like webdevelopment used to be, you don't need any complex software, and there are no complicated page lifecycle patterns that you have to get your head round. All you need is a copy of notepad, a cup of coffee and at least 4 hours.

I may very well start using PHP on all small sites I develop because it's simple. However I don't think I could deal with the headache of all those include files on larger sites. I'd be interested to take a look at the Facebook source code and see what it looks like as I've never saw the back end of a serious PHP development.


Currently rated 3.5 by 2 people

  • Currently 3.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories:
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Search Results

May 30, 2008 12:28 by thebeebs

Every week or so I take a look at the search terms that have brought people to my blog. It's often interesting and sometimes disappointing that so many come looking for something that my site so obviously doesn't provide.

Therefore I've decided to take a look at some of the search terms and answer all the questions that visitors have inadvertently asked through Google which the blog doesn't answer.

These are the top 20 Searches this month:

1. martin beeby
2. thoughtful gifts
3. millers hag
4. silverlight vs flex
5. flex alternatives
6. silverlight flex
7. diggsample.zip
8. flex silverlight
9. mcad .net blog
10. seadragon zoom
11. white men cant rap
12. "silverlight 2" ribbon 2008 controls 
13. acid 3
14. cant read
15. compare flex silverlight
16. flex silverlight comparison
17. funny letters
18. integrate windows live messenger
19. otex
20. regex helper

Now some of the search terms are dull and already answered somewhere on the blog, but below are a few that aren't and deserve a little more explanation.

2. thoughtful gifts
A thoughtful gift can't really be searched for? The whole idea is that you should put some thought into it! If your really struggling I always find tickets to a show are a good bet, rack your brain and try and remember something that she said she wanted to see. If you have more cash to splash stick with jewellery.

3. millers Hag
Millers hag are 4 piece band who I have no affiliation with but mentioned in one of my blogs you can find out more about them on the millers hag myspace page

5. flex alternatives
Silverlight is a great flex alternative this is a great place to start

7. diggsample.zip
You'll be looking for Scott gu's Digg sample which is on Scott's Blog

10. seadragon zoom

You should take a look at the brilliant video to see seadragon in action http://www.ted.com/index.php/talks/view/id/129

12. "silverlight 2" ribbon 2008 controls
As far as I can tell no one has yet released a good silverlight Ribbon Demo however Telerik have a good tab strip that could probably be extended: http://www.telerik.com/demos/silverlight/QSFEngine/index.html#Examples/TabStrip/FirstLook

13. funny letters

Hmmm how the hell did you get to my site? perhaps you should try: http://www.nwlink.com/~mikeblas/letters/index.htm

18. integrate windows live messenger
You need to check out http://msstudios.vo.llnwd.net/o21/mix08/08_WMVs/T03.wmv for a demo on integrating live messenger into anysite.

19. otex
It's pretty good stuff. You can find out more at http://www.otexear.com or buy on boots http://www.boots.com/guidedsearch/newsearch.jsp?searchArea=1&searchTerm=otex&uri=%2Fguidedsearch%2Fnewsearch.jsp&classificationId=&contentId=&articleId=&N=0&Ntk=all&Nty=1

20. regex helper
I use the regex workbench which can be downloaded here and is totally brilliant http://code.msdn.microsoft.com/RegexWorkbench/Release/ProjectReleases.aspx?ReleaseId=406


Currently rated 3.0 by 2 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories:
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

The Now you know phenomenon

May 29, 2008 09:30 by thebeebs

I heard a word the other month: Jingoistic, I'd never really heard it before so I looked it up. It means to have chauvinistic patriotism.

Funny thing was, it seemed like that that word kept popping up everywhere. I heard it on the radio twice and then read it in a magazine. I then found myself using it in a previous blog post.

This phenomenon isn't isolated to just the word Jingoistic, it happens to me all the time. It got me thinking surely there can only really be three explanations:

  1. The Interesting Explanation Two radio presenters read the magazine article which sparked their awareness which brought the word to the front of their mind causing them to use it, which in turn sparked my awareness of the word. I just so happened to listen to both presenters and then read the magazine.
  2. The Boring Explanation The word Jingoistic is used all the time, but because I didn't understand its meaning, I ignored it. It's only when I understood it's meaning that I took any notice at all.
  3. The Geek Explanation The world is like some sort of huge computer program and I'm the main character, and for some reason the player wants me to know the word Jingoistic for a future level.

Ok the geek explanation is unlikely but the other two are possibilities.


Currently rated 3.5 by 2 people

  • Currently 3.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories:
Actions: E-mail | Permalink | Comments (5) | Comment RSSRSS comment feed

Where's my B Side?

May 29, 2008 08:00 by thebeebs

I was reading today that Woolworths are planning to stop selling CD singles. Its a shame but I guess the format has had its day. One small problem will be that the good old fashioned B-side will be a thing of the past, which is a pity because it was a great way for artists to release songs that the record company didn't see as commercially viable. I remember Oasis B-sides were often better than the A side. Also a band called the Seahorse back in 1998ish had an incredible B-side called falling is easy, which I loved. RIP B-Sides.


Currently rated 2.5 by 2 people

  • Currently 2.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: Music
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Stupid Opinions

May 28, 2008 00:00 by thebeebs

“My name is earl is a television show and not reality”. Just thought I’d point that out to Sharon Stone who this week claimed that the Chinese earthquake that killed 80,000 people was Karma, settling the score because of Chinas human rights record in Tibet.

Apparently stone has an IQ of 154 - I imagine the figure of 154  was plucked out of the air between her ears, since surely no one with such a sharp brain would be so flippant as to attach a world wide disaster to a flaky belief like karma. I mean, even if she truly believes in Karma, can she not see how offensive it is to tell a family that they in some way deserved to lose their children.

I remember when an English football manager once said a similar thing about disabled children, claiming that they probably were evil in former lives and so their birth defects and disabilities were punishments.

Its one thing to have an opinion... its quite another to allow unfounded theories to be flaunted as a lesson to others.

Since Sharon so famously opened her legs in "Basic Instinct” perhaps Karma will be so kind as to shut her mouth.


Currently rated 3.3 by 3 people

  • Currently 3.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: General | News
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Bugger

May 27, 2008 14:54 by thebeebs

I just dropped my headphone in my coffee. It made me think... I bet that's quite a common office related incident. I wonder how many headphones a year are lost to Gold Blend?


Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories:
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Government databases

May 27, 2008 14:39 by thebeebs

I've been reading in the Press recently about the UK government plans to record all UK Email, Telecom's and Internet communication and store it in one central database.

Many of the newspapers seems to be of the opinion that this is to enable government agencies to have quicker access to the communication.

That reasoning really doesn't really make much sense to me, as spending billions on developing a system when you could just use the systems that the Telecom's Companies and ISP's are legally required to have, seems like a complete waste of time.

Surely the obvious reason that the government would want to do this is to attempt some form of Social network analysis to highlight potential terrorists.

For example each communication from Person A to Person B would be considered a "Vote". The more votes a person gets the more important they are. The government would point score known terrorists and the then would count each communication as a "Vote". Lets say Person A had a score of 1000, and he called Person B. Person B would be given 10 points. If Person C was assigned 2000 points and also called Person B, Person B would receive a further 20 points, taking his total to 30 points. Person B might then call  Person A and would therefore give Person A a further 3 points resulting in a total 2003 points.

After 500 or so iterations of the dataset (which would contain all of the UK communications) you'd eventually  end up with a list of people that score very highly that are almost certainly involved with terrorism to some extent.

Its precisely the same principle that is used by Google to rank pages, although Google uses hyper links (not phone calls and emails) as the "Vote" to determine the importance of another page, the idea and the result would be the same... relevant results.


Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories:
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed