SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 SQL GETDATE() function - Time is forward for 2 hou
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Bekios
Starting Member

Albania
3 Posts

Posted - 08/28/2014 :  06:22:31  Show Profile  Reply with Quote
Hello Everyone,

Hope you are fine.
I recently have added a field into table "Date Created", that has the Default Value or Binding GETDATE(). The problem is that when the insert is done to this table it is not getting Current Time, but the time is two hours forward.
Example: Lets say that the time now is 13:20 and when insert is done to this table(default value, without sending value to this field) it is getting the time 15:20 .

FYI: The insert is done throught a sql procedure that is executed from a program.

Any idea why is this happening.

Thanks for your answers in advance.

Best Regards,
B.C.

Edited by - Bekios on 08/28/2014 06:45:44

jackv
Flowing Fount of Yak Knowledge

United Kingdom
2076 Posts

Posted - 08/28/2014 :  07:47:04  Show Profile  Visit jackv's Homepage  Reply with Quote
the getdate() value comes from the operating system of the computer on SQL Server instance is running.
Could you confirm the value on the OS?

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

Bekios
Starting Member

Albania
3 Posts

Posted - 08/28/2014 :  09:24:58  Show Profile  Reply with Quote
Hello Jack,

Thanks for your response,


Could you confirm the value on the OS?

Can you explain me more how to find/confirm it?

I don't understand what you asked me in this questions!

Best Regards,
Go to Top of Page

gbritton
Flowing Fount of Yak Knowledge

1526 Posts

Posted - 08/28/2014 :  11:01:32  Show Profile  Reply with Quote
Open SSMS and any database. hit CTRL-N to start a new query. Type:


select getdate()

Go to Top of Page

Bekios
Starting Member

Albania
3 Posts

Posted - 08/28/2014 :  11:09:54  Show Profile  Reply with Quote
It Selects the correct Time, just when it is inserting from that program that executes the procedure it is inserting the wrong time, in this case two hours forward.
Go to Top of Page

gbritton
Flowing Fount of Yak Knowledge

1526 Posts

Posted - 08/28/2014 :  11:21:04  Show Profile  Reply with Quote
"when it is inserting from that program that executes the procedure it is inserting the wrong time"

Please post the complete definition of the procedure called by the program that does the insert operation

Go to Top of Page

Bustaz Kool
Flowing Fount of Yak Knowledge

USA
1770 Posts

Posted - 08/28/2014 :  18:50:43  Show Profile  Reply with Quote
Is the stored procedure supplying/generating the time or is it using the column's default? Is the default GETDATE() or GETUTCDATE()?



Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30281 Posts

Posted - 08/29/2014 :  02:53:23  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Even if you have a column with a default value doesn't mean an application can insert another value.
The default value is only stored if no value is supplied in the insert statement made by the application.



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000