Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Other Technologies / English Query / June 2008

Tip: Looking for answers? Try searching our database.

Getdate()+ so many hours

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian - 26 Jun 2008 13:57 GMT
Hi there

Hopefully this will be an easy one for someone. I am using SQL Server 2005.
I am based in the UK and our users are in the UK. We have recently changed
hosting providers and their server is located in the USA.

Our database has a default value of getdate() when a record is added however
as the server is set to the time in the USA, which I guess is for maintenance
reasons as it is a managed server. I was thinking that I would be able to add
or subtract the time difference on to this?

Does anyone have any idea of the syntax. I know that if it was plus a day I
would do something like getdate()+1 but how do you do it for part of a day?

Any help much appreciated.
Thanks
Brian
Russell Fields - 26 Jun 2008 14:03 GMT
Brian,

DATEADD (datepart, number, date)

Also, as a FWIW you can add GETDATE() + 0.333, but that is not what you are
after this time.

RLF

> Hi there
>
[quoted text clipped - 19 lines]
> Thanks
> Brian
Brian - 26 Jun 2008 14:25 GMT
This worked perfectly. I just worked out the difference was actually + 6
hours so I changed it to GETDATE()+0.25 and it seems to work a treat.

Thanks a million!

Brian

> Brian,
>
[quoted text clipped - 28 lines]
> > Thanks
> > Brian
Russell Fields - 26 Jun 2008 15:55 GMT
Brian,

But what is the effect of Daylight Savings Time on your application?  I ask
without doing all the research necessary to actually understand how US and
UK daylight savings time relate or fail to relate.  6 hours is easy, but 5
hours is not so easy by using decimals. (0.208333333333333...).   So, I
actually would suggest using DATEADD for date arithmatic.

However, it may be that GETUTCDATE() would serve you better in this case.

RLF

> This worked perfectly. I just worked out the difference was actually + 6
> hours so I changed it to GETDATE()+0.25 and it seems to work a treat.
[quoted text clipped - 39 lines]
>> > Thanks
>> > Brian
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.