Archive

Archive for January, 2009

String Formatting in C#

January 27th, 2009 No comments

Original Article

I couldn’t find a quick reference to .NET string formatting using the String.Format() function, so I created this one (which has also spawned this String Formatting FAQ and strangely enough, this cartoon. Read more…

Categories: c# Tags:

100% Height Layout Using CSS

January 27th, 2009 No comments

Published by Dave 

CSS layouts don’t have to be complicated but sometimes the things that should be simple and easy to do seem impossible at first.

Read more…

Categories: css Tags:

CSV, CDF string – Multiple In by string IN(“1,2,3,4,5″) etc

January 27th, 2009 No comments
CREATE FUNCTION CSVTable(@Str VARCHAR(7000))
RETURNS @t TABLE (numberval INT, stringval VARCHAR(100), DateVal datetime)
AS
BEGIN
 
DECLARE @i INT;
DECLARE @c VARCHAR(100);
 
SET @Str = @Str + ','
SET @i = 1;
SET @c = '';
 
while @i <= len(@Str)
BEGIN
IF SUBSTRING(@Str,@i,1) = ','
BEGIN
INSERT INTO @t
VALUES (CASE WHEN isnumeric(@c)=1 THEN @c ELSE NULL END,
rtrim(ltrim(@c)),
CASE WHEN isdate(@c)=1 THEN @c ELSE NULL END)
SET @c = ''
END
ELSE
SET @c = @c + SUBSTRING(@Str,@i,1)
SET @i = @i +1
END
RETURN
END

Read more…

Categories: SQL Tags:

Essential SQL Server Date, Time and DateTime Functions

January 27th, 2009 No comments

Essential SQL Server Date, Time and DateTime Functions

(2/13/07 Update: Once again, some great feedback has given us an even better Date() function — and a Time() function as well.  Thank you Michael !)

Read more…

Categories: SQL Tags:

Get Largest date

January 27th, 2009 No comments
CREATE FUNCTION fn_greatest_date
   (@date_1 datetime, @date_2 datetime, @date_3 datetime)
RETURNS datetime
AS
BEGIN
    DECLARE @return_date datetime
    SELECT @return_date = MAX(dateval)
    FROM
    (    SELECT @date_1 AS dateval UNION ALL
        SELECT @date_2 UNION ALL
        SELECT @date_3
    ) dates
 
 <a href="http://www.fruitbatscode.com/sql/get-largest-date#more-9" class="more-link">Read more...</a>
Categories: SQL Tags:

Check if an image exits.

January 26th, 2009 Comments off

Javascript can be used to check if an image exist. An AJAX call cannot be used, because cross-site calls are not supported. However, the javascript Image object can be used for this purpose.

var img = new Image();
 
 <a href="http://www.fruitbatscode.com/javascript/check-if-an-image-exits#more-4" class="more-link">Read more...</a>
Categories: Javascript Tags: