Tuesday, November 2, 2010

how to select records of particular date from a sql table if time is also there?

query for select all records.
select * from tbltable

 


query for select record for particular date
select * from tblTable where dDate='10/29/2010'
but because of time there is no record retrieved in result
now if you want to record from a particular date not including time use this query
select *  from tbltable 
where DateAdd(day, datediff(day,0, dDate), 0)=DateAdd(day, datediff(day,0, '10-29-2010'), 0)

Tuesday, October 12, 2010

case statement in sql query.

SELECT col1,col2,col3,
case col4 when 0 
 then 'Approve'
 else 'Un-Approve'
 end as Approved as 'Colum4',
col5      
  FROM tblTest

Tuesday, September 7, 2010

How to Set Dynamically order by Clause in sql Query ?

DECLARE @iSort int
SET @iSort = 3
SELECT * FROM tableName
order by
case when @iSort = 1 then Column1 end asc,
case when @iSort = 2 then Column2 end desc,
case when @iSort = 3 then Column3 end asc,
case when @iSort = 4 then Column4 end desc

Saturday, August 28, 2010

How to Show and Hide Div Using JavaScript?

Java Script Code

html Code
Step First 
        Step Second
    
This is Step Two Panel

How to Convert Number in Indian Currency format(like lakh and crore format)?

A method to convert any number in indian curreny format in words.
public string NumberToText(int number)
    {

        if (number == 0) return "Zero";

        if (number == -2147483648) return "Minus Two Hundred and Fourteen Crore Seventy Four Lakh Eighty Three Thousand Six Hundred and Forty Eight";

        int[] num = new int[4];
        int first = 0;
        int u, h, t;
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        if (number < 0)
        {
            sb.Append("Minus ");
            number = -number;
        }

        string[] words0 = {"" ,"One ", "Two ", "Three ", "Four ", 
"Five " ,"Six ", "Seven ", "Eight ", "Nine "};

        string[] words1 = {"Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", 
"Fifteen ","Sixteen ","Seventeen ","Eighteen ", "Nineteen "};

        string[] words2 = {"Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", 
"Seventy ","Eighty ", "Ninety "};

        string[] words3 = { "Thousand ", "Lakh ", "Crore " };

        num[0] = number % 1000; // units 
        num[1] = number / 1000;
        num[2] = number / 100000;
        num[1] = num[1] - 100 * num[2]; // thousands 
        num[3] = number / 10000000; // crores 
        num[2] = num[2] - 100 * num[3]; // lakhs 

        for (int i = 3; i > 0; i--)
        {
            if (num[i] != 0)
            {
                first = i;
                break;
            }
        }


        for (int i = first; i >= 0; i--)
        {
            if (num[i] == 0) continue;

            u = num[i] % 10; // ones 
            t = num[i] / 10;
            h = num[i] / 100; // hundreds 
            t = t - 10 * h; // tens 

            if (h > 0) sb.Append(words0[h] + "Hundred ");

            if (u > 0 || t > 0)
            {
                if (h > 0 || i == 0) sb.Append("and ");

                if (t == 0)
                    sb.Append(words0[u]);
                else if (t == 1)
                    sb.Append(words1[u]);
                else
                    sb.Append(words2[t - 2] + words0[u]);
            }

            if (i != 0) sb.Append(words3[i - 1]);

        }
        return sb.ToString().TrimEnd();
    }

Monday, August 23, 2010

Auto Generated Serial Number in a SQL Query

select ROW_NUMBER() over (order by ID) as RowNumber from tableName

How to Convert Date in dd-MM-yyyy format in Sql ?

select convert(varchar(50),getdate(),105)

What is partial Class in ASP .NET C-Sharp ?

Instead of defining an entire class, you can split the definition into multiple classes by using the partial keyword. When the application is complied, the C# complier will group all the partial classes together and treat them as a single class. There are a couple of good reasons to use partial classes. Programmers can work on different parts of a class without needing to share the same physical file. Also you can separate your application business logic from the designer-generated code

How to access server control in javascript in asp .net ?

This is your Server Control

and this is JavaScript code to access asp .net server control in javascript

How to Create Dynamic Datatable ?

public Datatable DynamicDataTable
{
        DataTable dt = new DataTable();
        dt.Columns.Add("year", typeof(string));
        DataRow dr = null;
        for (int i = 2005; i <= DateTime.Now.Year; i++)
        {
            dr = dt.NewRow();
            dr["year"] = i.ToString() + "-" + (i+1).ToString().Substring(2);
            dt.Rows.Add(dr);
        }
return dt;
}