April 6, 2009 at 1:53 am
kruti (4/6/2009)
here is the output of both functions.GetDate(): 2009-04-06 13:06:29.197
Solution by Flo: 2009-04-06 12:54:29.193
Solution by Paul: 2009-04-06 12:54:29.193
You didn't tell us what the input was!
The 4ms difference is odd, I assume it is down to the timing of your test statements?
At least Flo and I are consistent!
🙂
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
April 6, 2009 at 2:01 am
hey, 1st of all, sorry for the incomplete information....
here is go..
select getDAte() 'GetDate', dbo._fnFlo('GMT::5:30') 'Sln by Flo', dbo.fnPaul(5.3) 'Sln by Paul'
and as seen, i got above result in single query... 🙁
"Don't limit your challenges, challenge your limits"
April 6, 2009 at 2:10 am
Paul White (4/6/2009)
Apologies to flo who posted at the same time - but I'd already written this so I have to post it! 😀
Nothing to apologize, I just did the same in another thread 😀
I've to go to a meeting now... :doze:
@kruti: I will answer you when I'm back.
Greets
Flo
April 6, 2009 at 2:18 am
@Flo:
Yes I've just seen it (the cascade)...spooky!
@Kruti
I'm going to assume the results are right then (your time zone is GMT +5 or something?)
The 4ms timing difference came about, I imagine, from the query plan executing the functions first, then the explicit call to GetDate(). If this is a problem, you could always store a value for the current GetDate in a local variable, and pass that to both functions in an extra parameter.
Cheers,
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
April 6, 2009 at 2:31 am
Meeting is in one hour...
Paul White (4/6/2009)
@Flo:Yes I've just seen it (the cascade)...spooky!
😀
@Kruti
I'm going to assume the results are right then (your time zone is GMT +5 or something?)
The 4ms timing difference came about, I imagine, from the query plan executing the functions first, then the explicit call to GetDate(). If this is a problem, you could always store a value for the current GetDate in a local variable, and pass that to both functions in an extra parameter.
Cheers,
Paul
I can confirm. It works well on my system.
Greets
Flo
April 6, 2009 at 2:43 am
"The 4ms timing difference came about, I imagine, from the query plan executing the functions first, then the explicit call to GetDate(). "
In any case the getDate() function will return value having 12mins more.. (which matches with my current system date... obviously.. :-P)
humm.. it makes me paused now...
"Don't limit your challenges, challenge your limits"
April 8, 2009 at 5:20 am
Hey Flo/Paul,
thanks guys for helping me.
The problem in my code was, i was converting date with approx value in floating point terms. At last, we all come to one common solution :hehe:
DATEADD(SECOND, (5.30 * 3600), GetUTCDate())
or
DATEADD(MINUTE, 60 * 5.30, GetUTCdate())
{here, 5.30 is for IST timezone, ie, GMT 5.30}
"Don't limit your challenges, challenge your limits"
April 8, 2009 at 5:38 am
kruti (4/8/2009)
Hey Flo/Paul,thanks guys for helping me.
The problem in my code was, i was converting date with approx value in floating point terms. At last, we all come to one common solution :hehe:
DATEADD(SECOND, (5.30 * 3600), GetUTCDate())
or
DATEADD(MINUTE, 60 * 5.30, GetUTCdate())
{here, 5.30 is for IST timezone, ie, GMT 5.30}
For IST (UTC+05:30), you should use an hour correction of 5.50 (decimal) not 5.30.
DATEADD(SECOND, (5.50 * 3600), GetUTCDate())
DATEADD(MINUTE, 60 * 5.50, GetUTCdate())
April 8, 2009 at 5:53 am
For IST (UTC+05:30), you should use an hour correction of 5.50 (decimal) not 5.30.
DATEADD(SECOND, (5.50 * 3600), GetUTCDate())
DATEADD(MINUTE, 60 * 5.50, GetUTCdate())
yeah!! i also notice this thing....
But I am confused, as IST timezone is GMT 5.30, then how come to add 5.50!!!?
"Don't limit your challenges, challenge your limits"
April 8, 2009 at 7:05 am
+05:30 means 5 hours 30 minutes, not 5.30 hours
I blame the Babylonians 😉
April 8, 2009 at 10:34 am
andrewd.smith (4/8/2009)
+05:30 means 5 hours 30 minutes, not 5.30 hoursI blame the Babylonians 😉
That is a good one but I am not sure you can blame the Babylonians because Microsoft is not using that era in DateTime and in Timezone you can actually your politicians because here in US the government makes adjustments as needed.
😉 :Whistling:
Now to the OP if your application is .NET in .NET 3.5 there is built in Timezone class you can use if you are not in .NET 3.5 then you need to use existing code. So let me know if your application is .NET and what version.
Kind regards,
Gift Peddie
April 8, 2009 at 11:07 pm
+05:30 means 5 hours 30 minutes, not 5.30 hours
Yeah i know that 5.30 in timezone shows 5hr 30mins... but sql took it .30 after 5, that came into my conscious just now.. good lesson for the day.. 🙂
@peddie
I am not using .NET by all my apps. I hv many apps developing in VB, ASP, ASP.NET, Delphi... i m working at multi-langue platform....
"Don't limit your challenges, challenge your limits"
April 9, 2009 at 7:39 am
I am not using .NET by all my apps. I hv many apps developing in VB, ASP, ASP.NET, Delphi... i m working at multi-langue platform....
What exactly is multi-langue platform that does not use .NET because if it is just multi langauge as in more than one langauge you could always consume a .NET dll.
The reason this is 2005 all you need is .NET 3.5 CLR package to generate your timezone data on your client.
Kind regards,
Gift Peddie
April 9, 2009 at 7:46 am
Gift Peddie (4/9/2009)
I am not using .NET by all my apps. I hv many apps developing in VB, ASP, ASP.NET, Delphi... i m working at multi-langue platform....
What exactly is multi-langue platform that does not use .NET because if it is just multi langauge as in more than one langauge you could always consume a .NET dll.
The reason this is 2005 all you need is .NET 3.5 CLR package to generate your timezone data on your client.
Hi Gift!
I cannot attest, but I'm quiet sure that every programming language has any method to get the current time-zone.
Greets
Flo
April 9, 2009 at 7:52 am
I cannot attest, but I'm quiet sure that every programming language has any method to get the current time-zone.
Timezone is based on politics so there was none in SQL Server before 2008 and in .NET it is new to .NET 3.5, I cannot say for other langauges but this application runs in 2005 so a CLR package is a very simple solution.
Kind regards,
Gift Peddie
Viewing 15 posts - 16 through 30 (of 40 total)
You must be logged in to reply to this topic. Login to reply