Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
2 total  XML / RSS feed 

Selecting different parts of a DATETIME with MSSQL

Thanks to this website for the information:

http://www.databasejournal.com/features/mssql/article.php/1442021

-- The syntax for pulling a certain part of a DATETIME is:
--
-- CONVERT(date_type[(length)],expression[,style])
--
-- The available styles are as follows:
--
-- NULL  Jun 24 2001 9:48PM
-- 1     06/24/01
-- 101   06/24/2001
-- 2     01.06.24
-- 104   24.06.2001
-- 108   21:48:00
-- 112   20010624
-- 121   2001-06-24 21:48:00.000

-- Some example usage:
SELECT CONVERT(DATETIME,GETDATE(),112) as date
-- Will output in YYYYMMDD format
SELECT CONVERT(DATETIME,client.birthday,101) as birthday
-- Will output in MM/DD/YYYY format

Meta programming in D

Implementing guards in D

import std.stdio;
bool guarded( lazy void cmd, bool delegate()[] guards ...){
  bool lazyOr= false;
  foreach( g; guards) {
    if( lazyOr |= g()) break;
  }
  bool yn= !lazyOr;
  if( yn) cmd();
  return yn;
}
bool guard( lazy bool exp, lazy void action){
  bool yn= exp;
  if( yn) action();
  return yn;
}
void main(){
  int i=2;
  guarded( {
      writefln("yes");
      writefln("must i");
    }(),
      guard( i==0, writefln("null")),
      guard( i==1, writefln("one"))
  );
}
« Newer Snippets
Older Snippets »
2 total  XML / RSS feed