Tag: datetime

c# conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value

I am putting together a C# Asp.net MVC site. One of the models is SystemUser as shown here public class SystemUser : DefaultModel { public int Id { get; set; } [Required] [StringLength(50, ErrorMessage = “First name cannot be longer than 50 characters.”)] [Column(“FirstName”)] [Display(Name = “First Name”)] public string FirstName { get; set; } […]

T-SQL Looking for the most concise way to summarize a starting and ending date range

Really long story short, I have two datetime fields in a table that I am loading into variables @DateFrom and @DateTo, and I need to “explain” what sort of range they cover in text for presentation on the screen. Although the fields are datetime, the time component will be ignored. I am also declaring @Current […]

How do I fix date in sql server that does not have a proper Day, Month and Year order

How do I fix date in sql server that does not have a proper day, month and year order? I’d like to fix this in both sql server and Cognos and apply the standard date format MM/DD/YYYY format. But some records in the Date column (Date of Death column). Some records are on the MM/DD/YYYY […]

Convert DateTime to nvarchar

I have a table with column of the type nvarchar. I’m going through the following parameter: cmd.Parameters.Add(“@PointDate”, SqlDbType.NVarChar).Value = DateTime.Now; and as expected’m getting the error: Additional information: Error converting data type nvarchar to datetime. How to convert DateTime to nvarchar?

SQL Server Job history 2008 R2

I have many jobs scheduled in SQL Server R2. And each job may contain several Steps under it. I want the lastrundate, lastrunstatus, lastrunduration, lastrunmessage, nextrundate FOR EACH AND EVERY STEP under EACH JOB. I have this query with me which works fine. The only issue is, it is not allowing me to convert the […]

Why can't I use a datetime parameter in ssrs?

I have an SSRS Date/Time parameter generated from a shared dataset query against a SQL Server datetime field. The parameter displays correctly in a report textbox but it will not work in an embedded dataset query, even against the same table that the datetime value was generated from. In order to use the parameter for […]

SQL Filter Out Specific Month, Day, and Time for Any Year

Microsoft Dynamics NAV uses the datetime of yyyy-12-31 23:59:59.000 to identify yearly closing entries. I am trying to write a report that will bring all of my entries, except for these. The query works fine for 2014 if I explicitly use a WHERE clause of WHERE [Posting Date] <> ‘2014-12-31 23:59:59.000’) But I need the […]

use datetime instead of datetime2 sqlserver hibernate

I have hibernate configured as auto-update. I have a mssql-server 2012. Hibernate creates my java.util.Date objects as datetime2 in the database. Is there a possiblity to force hibernate to create datetime in the database? I know that I can use annotations on the fields in my object, but there are too many. So I would […]

Updating DateTime columns failed when converting date

Help. I have some records that have been inserted differently into a DATETIME column. When my sproc executes I receive this error: “Conversion failed when converting date and/or time from character string.”. Is there any way to convert the bad datetime into the normal default DATETIME format? Good: Bad: ;with t1 as ( select s1.SheetID […]

Assume local instead of Unspecified DateTime from SQL Server

Because the SQL Server datatype datetime does not keep any timezone information, the SqlClient in .NET is instantiating all DateTime objects with Kind set to DateTimeKind.Unspecified. That is of cause the right thing to do – theoretically. BUT almost every application I have worked on has stored datetime assuming it to be local, and lived […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.