Wednesday, July 25, 2007
[SQL] Convert VARCHAR To VARBINARY
Usefull for hinding a value.
DECLARE @Password varchar(50)
SET @Password = 'MLAV'
SELECT CONVERT(varbinary(50), @Password)
DECLARE @Password varchar(50)
SET @Password = 'MLAV'
SELECT CONVERT(varbinary(50), @Password)
Wednesday, July 18, 2007
[ASP.Net] Get Object Value from User Control
[C#]
UserControl.FindControl method
TextBox firstNameTextBox = (TextBox) uc1.FindControl("firstNameTextBox");
UserControl.FindControl method
TextBox firstNameTextBox = (TextBox) uc1.FindControl("firstNameTextBox");
Wednesday, July 11, 2007
[SQL] Get Number of Days in a Month Function
REATE FUNCTION [dbo].[GetDaysInMonth] ( @pDate DATETIME )
RETURNS INT
AS
BEGIN
RETURN CASE WHEN MONTH(@pDate) IN (1, 3, 5, 7, 8, 10, 12) THEN 31
WHEN MONTH(@pDate) IN (4, 6, 9, 11) THEN 30
ELSE CASE WHEN (YEAR(@pDate) % 4 = 0 AND
YEAR(@pDate) % 100 != 0) OR
(YEAR(@pDate) % 400 = 0)
THEN 29
ELSE 28
END
END
END
GO
[C#.Net] Code: Determining the Span Between Two Dates
DateTime oldDate = new DateTime(2002,7,15);
DateTime newDate = DateTime.Now;
// Difference in days, hours, and minutes.
TimeSpan ts = newDate - oldDate;
// Difference in days.
int differenceInDays = ts.Days;
Console.WriteLine("Difference in days: {0} ", differenceInDays);
Download Compiled Code : http://ayette.net/ComputeHoursWork.rar
Download Sample Code: http://ayette.net/ComputeHoursWork.rar
[VB.Net] Get Last Day of the Month
Function LastOfThisMonth() As Date
LastOfThisMonth = DateAdd("d", -1, FirstOfNextMonth)
End Function
Function FirstOfNextMonth() As Date
Dim dtm As Date
dtm = Date
FirstOfNextMonth = DateSerial(Year(dtm),
Month(dtm) + 1, 1)
End Function
Subscribe to:
Posts (Atom)