All Questions
Tagged with datetime sql-server-2012
16 questions
7
votes
1
answer
4k
views
SQL Server 2012 equivalent of AT TIME ZONE capability
Is there a way in SQL Server 2012 to get what the server time zone would be on a particular date/time? In SQL Server 2016, you have AT TIME ZONE, but that's not available in 2012. I have a ...
-2
votes
1
answer
391
views
Convert Varchar to Datetime
I have a database field Column_A which is in Varchar(16) not null and the values are for example 20191210215033CS but I want to break it like 2019-12-10 21:50:33
Since it is a production database ...
2
votes
1
answer
138
views
Date time cast preferred method
What would be the preferred method for speed and less database stress using a between or less than?
SELECT LogId
FROM [Master].[dbo].log mlog
WHERE cast(LogDate as Date) BETWEEN '2019-01-01' AND '2019-...
1
vote
1
answer
132
views
Subtracting Days From Current Date
I know this is probably very basic, but I'm trying to create a calculated field that subtracts X number of from Current Date, based off of the value of another field:
CASE WHEN DaysPD = 30 THEN 1
...
0
votes
1
answer
4k
views
CONVERT to datetime fails on Dynamic SQL - "Conversion failed when converting date and/or time from character string" [closed]
I've spent a few hours with this and still can't get it to work. I'm trying to get the path to the most recent file that matches a pattern for a dynamic SQL query where I'm loading a CSV file into a ...
1
vote
1
answer
2k
views
SQL Server datetime column datatype stores offset
Does the SQL Server datetime column have the capability to store the offset of the time?
I'd like to store a value like
YYYY-MM-DDThh:mm:ss±hh
e.g.
2015-07-14T10:08:15+01
But when I insert the ...
1
vote
2
answers
3k
views
How to Concatenate DateTime to nvarchar field
I have a table with a nvarchar(32) column and I want to update the value in this column with the first 10 bytes of another field on the table which is defined as nvarchar(32) after the 10 bytes I want ...
1
vote
3
answers
583
views
DateTime value has additional hour after insert
I developed a Windows Service (with a fixed culture of "de-DE") in C#. This service is getting data from an API and copies it over to a Navision Database.
My problem is following: After I've copied ...
1
vote
3
answers
9k
views
How do we get an hour, minute and second difference between two datetimes?
The table Task has columns as:
Task(TaskID, TaskName, CreatedDate)
And want to execute code block based on datetime difference as:
IF Task CreatedDate has passed 15 Minute THEN
Execute block #01
...
0
votes
1
answer
738
views
Converting date string to SQL DATETIME - hopefully without a udf
I am taking an Excel file that has dates in different formats but one of these formats is giving me some grief when I try converting it or casting it to a SQL DATETIME. For example:
Thu Oct 16 13:40:...
16
votes
3
answers
191k
views
SQL Server Isnull Returning 1900-01-01 when field is null
The following piece of code is returning 1900-01-01 when the DOB field is null. I wanted (and expected) it to return an empty string ('') but it's not. How should I proceed to get my desired results?
...
5
votes
2
answers
5k
views
Datetime column vs Date + Time columns
I am designing a table for a system that saves a number of logs. We are looking at ~200 entries per second.
We are using SQL-Server 2012 Enterprise Edition.
I have a question regarding breaking up a ...
2
votes
2
answers
1k
views
SQL Server and SharePoint time problem
I have created a SharePoint application which has a specific time zone.
The Windows server where SQL Server and SharePoint are installed are using same time zone.
When I create a new item in list ...
14
votes
2
answers
10k
views
Handling time zones in data mart/warehouse
We are starting to design the building blocks of a data mart/warehouse and we need to be able to support all time zones (our clients are from all over the world). From reading discussions online (and ...
3
votes
2
answers
40k
views
Should I join datetime to a date using cast or range?
This question is a take-off from the excellent one posed here:
Cast to date is sargable but is it a good idea?
In my case, I am not concerned with the WHERE clause but in joining to an events table ...
1
vote
1
answer
2k
views
Advice needed for Querying DateTimeOffset data by end users
We are building an Operational Data Store (ODS). The data is coming from our production databases which are located in the United States and Asia. The data in our production databases store date/time ...