If I have a start and end date, and then a separate start and end time, I would like to return the time range for each of the days in the date range. Here’s a small example: I have the following variables set to the following sample values: declare @StartDate date declare @EndDate date declare […]
I’m using SQL Server ADSI to import data from Active Directory and using the whenChanged field to control if I need to reimport the members of a group. Problem is the date is being returned in GMT and I’m currently in BST. So, did a member change at 9:50 this morning, the AD tools I […]
Our current app stores all dates via the server’s datetime. I’m thinking we need to update all datetime values in the database over to UTC time. Now for displaying these dates back to the user, I know .Net 3.5 has datatypes that are specific to date time offsets. But does anyone see anything wrong with […]
I have a problem. I have an application in C# with SQL SERVER 2005 as backend. The problem is in fetching the correct record based on the date. The frontend code is if (string.IsNullOrEmpty(txtFromDate.Text)) SelectCmd.Parameters.Value = DBNull.Value; else SelectCmd.Parameters.Value = txtFromDate.Text; Now if I run usp_NewGetUserDetail ’03/04/2010′ in the query analyser, I am able to […]
Consider this simple user defined function: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER FUNCTION [dbo].[ufn_GetFirstDayOfMonth] ( @pInputDate DATETIME ) RETURNS DATETIME BEGIN RETURN CAST(CAST(YEAR(@pInputDate) AS VARCHAR(4)) + ‘/’ + CAST(MONTH(@pInputDate) AS VARCHAR(2)) + ‘/01′ AS DATETIME) END which when run using: SELECT [Business].[dbo].[ufn_GetFirstDayOfMonth] (’03/13/15’) Returns, 2015-03-01 00:00:00.000. Fantastic, exactly what i wanted. Now suppose […]
I have a series of datetime values. I want to select records with a difference of 2 or more hours between them. 2010-02-11 08:55:00.000 2010-02-11 10:45:00.000 2010-02-11 10:55:00.000 2010-02-11 12:55:00.000 2010-02-11 14:52:00.000 2010-02-11 16:55:00.000 2010-02-11 17:55:00.000 2010-02-11 23:55:00.000 2010-02-12 00:55:00.000 2010-02-12 02:55:00.000 Expected (The next date compared is with the last date that qualified for […]
I want only Hr and Min in time format so i did select convert(varchar(20),GETDATE(),108) ===>> output is “12:57:54″ but i want only “12:57” this much so how i will do that in sql server
I need to solve the following problem for one of my clients. They have an installer which installs a SQL server database + IIS website. The SQL database user can have any kind of date format (DD/MM/YYYY, MM/DD/YYYY,…) depending on the locale of the sql server. The IIS website can have any kind of date […]
I have an int field (Days) in myTable. How can I format it to Year-Month-Day String? Wanna do this with T-SQL SQL Server 2008. For example ; 65 Days = 0 Year 2 Month 5 Day like this. Thanks.
I’m trying to check my transactions in database that occured before midday or “12:00:00”. But the compared field datatype is datetime, like “00:00:00”. Therefore I want to query the transactions that get time stamp before 12:00:00 in SQL Commands. My database is SQL Server 2005. Hope everybody can help me to solve this problem.