Monday, May 31, 2010

TSQL date

declare @StartDate datetime
,@EndDate datetime
set @StartDate = dateadd(d,-1, convert(datetime,convert(varchar(11),getdate(),109),109))
set @EndDate = @StartDate+1
select @StartDate,@EndDate


select * from table
where timevalue >= @StartDate and TimeValue < @EndDate

Sunday, May 30, 2010

jquery

$("select[ID^='Note_']").click(function() {
var currID = $(this).attr("id");
var $options = $('option', $(this));
$options.each(function() {
$(this).text($(this).text() + $(this).attr("title"));
});
});
$("select[ID^='Note_']").bind("blur", function(event) {
//alert($(this).val());
var currID = $(this).attr("id");
var $options = $('option', $(this));
$options.each(function() {
$(this).text($(this).value());
});
});

Friday, May 28, 2010

SELECT DISTINCT

Interesting alternative to using SELECT DISTINCT if you’re loading results into a dataset. The following line creates a DataTable with only distinct rows:

DataTable dtDistinctData = dsData.Tables[0].DefaultView.ToTable(true);

Sunday, April 18, 2010

How to stop printing blank pages

How to stop printing blank pages
If you are getting blank pages when you are printing a worksheet, then there are a number of possibilities:

1. You have some ‘unnoticed’ text in one of the cells, e.g. ‘.’ or ‘,’.

2. You have cells that contain text, but the text color is the same as the cell background color.

3. You have a cell with a formula that returns a blank value.

4. You have empty cells that are formatted with borders or shading.

5. You have set a print area that spans into more than one page.

Possible Resolutions:

1. For unnoticed text, press CTRL+END to find the last non-blank character, and delete it if it is not required. Repeat the process if necessary.

2. For formulas, display formulas by pressing CTRL+’~’ then try to find the formula that returns a blank value.

3. Set the print area to the required cells only. Read more.

Thursday, October 8, 2009

How to Add, Remove ListItems from one ListBox to Another in JQuery?

$(document).ready(function() {
$("#btnAdd").click(function() {
$("#ListBox1 > option[@selected]").appendTo("#ListBox2");
});
$("#btnAddAll").click(function() {
$("#ListBox1 > option").appendTo("#ListBox2");
});
$("#btnRemove").click(function() {
$("#ListBox2 > option[@selected]").appendTo("#ListBox1");
});
$("#btnRemoveAll").click(function() {
$("#ListBox2 > option").appendTo("#ListBox1");
});
});



1
2
3





Tuesday, September 8, 2009

DataRow drBlank = dsList.Tables[0].NewRow();
drBlank["IsLabelPrinted"] = 0;
drBlank["GroupID"] = -1;
dsList.Tables[0].Rows.Add(drBlank);
dsList.AcceptChanges();

IP address regex

///
/// Validate that String is an IP address.
/// Between 0.0.0.0 and 255.255.255.255
///

protected Regex regIP = new Regex(
@"(?2[0-4]\d|25[0-5]|[01]?\d\d?)\.(?2[0-4]\d|25"
+ @"[0-5]|[01]?\d\d?)\.(?2[0-4]\d|25[0-5]|[01]?\d\d?)\.(?"
+ @"2[0-4]\d|25[0-5]|[01]?\d\d?)",
RegexOptions.IgnoreCase
| RegexOptions.CultureInvariant
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);