riki
riki

Reputation: 1715

Incorrect time entry in datetime sql server format

Hi the query below performs an insert on sql server, when the insert is done date minutes and seconds are correct but the time is wrong (if there are 8 and I insert an insert the value is saved 7) the format of the hours is that Italian, below the sql code that executes the insert. How do I solve this?

Sql Server:

Insert into Magazzino(Nome,Indirizzo,DataCreazione) 
values(@Nome,@Indirizzo,convert(datetime, GETDATE(),105))

Upvotes: 0

Views: 1548

Answers (1)

Code Maverick
Code Maverick

Reputation: 338

Documentation states that GETDATE() stores the date and time of the computer on which the instance of SQL server is running. To resolve this, you have two options:

  • Update configuration of SQL server instance. See this - this may require Operations/MIS support.
  • Use datetimeoffset on GetUTCDate(). See this.

P.S.: Kindly change the tag of this question to t-sql or sql-server!

Upvotes: 1

Related Questions