Wish list
If you like this blog and want to say thanks in some way, here is my wish-list on Amazon. It'll be very cool to get a gift from my subscribers. Just don't forget to put your name on it -)Tags
Tag Archives: dates
Parse Hrnet Date
Simple snippet for Custom Scripts: convert form HRNET date string into JavaScript format /** * Parce from string representind date in format “dd/mm/yyyy” into JavaScript Date format */ function parseDate(strDate){ var array = strDate.split(“/”); return new Date(array[2], array[1]-1, array[0], 0,0,0); … Continue reading
Find End of a Day for Given Date
Determines the last second for the day for the given date CREATE FUNCTION [dbo].[EndOfDay] ( @DATE DATETIME ) RETURNS DATETIME AS BEGIN RETURN DATEADD(s,-1,DATEADD(d, DATEDIFF(d,0,@DATE)+1,0)) END
Find Start of a Year for Given Date
Finds out a start of the year for the given date. CREATE FUNCTION [dbo].[StartOfYear] ( @DATE DATETIME ) RETURNS DATETIME AS BEGIN RETURN DATEADD(yy, DATEDIFF(yy,0,@DATE),0) END
Find Start of a Month for Given Date
Finds Start of the month with given date CREATE FUNCTION [dbo].[StartOfMonth] ( @date datetime ) RETURNS datetime AS BEGIN return DATEADD(M,-1,DATEADD(mm, DATEDIFF(m,0,@date)+1,0)) END
End of Month for Given Date
Finds end of the month with given date Create FUNCTION [dbo].[EndOfMonth] ( @date datetime ) RETURNS datetime AS BEGIN return DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@date)+1,0)) END
End of a Year for Given Date
Function to find latest second of the year for the given date Create FUNCTION [dbo].[EndOfYear] ( @DATE DATETIME ) RETURNS DATETIME AS BEGIN RETURN DATEADD(s, -1, DATEADD(yy, DATEDIFF(yy,0,@DATE)+1,0) ) END