Skip to main content

Posts

Showing posts from April, 2013

ASP.NET DATE FORMAT CUSTOME

string SSS = DateTime.Now.ToString("dddd, d MMMM, yyyy", CultureInfo.CreateSpecificCulture("en-US")); DateTime date1 = new DateTime(2008, 8, 29, 19, 27, 15); Console.WriteLine(date1.ToString( "ddd d MMM" , CultureInfo.CreateSpecificCulture( "en-US" ))); // Displays Fri 29 Aug Console.WriteLine(date1.ToString( "ddd d MMM" , CultureInfo.CreateSpecificCulture( "fr-FR" ))); // Displays ven. 29 août      DateTime date1 = new DateTime(2008, 8, 29, 19, 27, 15, 18); CultureInfo ci = CultureInfo.InvariantCulture; Console.WriteLine(date1.ToString( "hh:mm:ss.f" , ci)); // Displays 07:27:15.0 Console.WriteLine(date1.ToString( "hh:mm:ss.F" , ci)); // Displays 07:27:15 Console.WriteLine(date1.ToString( "hh:mm:ss.ff" , ci)); // Displays 07:27:15.01 Console.WriteLine(date1.ToString( "hh:mm:ss.FF" , ci)); // Displays 07:27:15.01 Console.WriteLine(date1.

SQL PARENT CHILD TREE STRUCTURE

-- DECLARE DECLARE @Company AS TABLE(EmpID INT, ParentID INT, PersonName VARCHAR(100)); -- Insert Temp Records INSERT INTO @Company(EmpID, ParentID, PersonName) VALUES(1 , NULL , 'Maulik Dhorajia')     , (2 , NULL , 'Bhavesh Gohel')     , (3 , NULL , 'Dinesh Padhiyar')     , (4 , 2 , 'Vijay Kumar')     , (5 , 1 , 'Jitendra Makwana')     , (6 , 4 , 'Jayesh Dhobi')     , (7 , 1 , 'Shivpalsinh Jhala')     , (8 , 5 , 'Amit Patel')     , (9 , 3 , 'Abidali Suthar') -- Default data SELECT * FROM @Company; -- Incorrect result which we usually find on Internet ;WITH CTECompany AS (     SELECT EmpID, ParentID, PersonName , 0 AS HLevel     FROM @Company     WHERE ParentID IS NULL         UNION ALL         SELECT C.EmpID, C.ParentID, C.PersonName , (CTE.HLevel + 1) AS HLevel     FROM @Company C     INNER JOIN CTECompany CTE ON CTE.EmpID = C.ParentID     WHERE C.ParentID IS NOT NULL ) -- Misleading SQL SELECT * FROM (     SELEC