September 22, 2010 at 10:19 am
You can even leave a comment as to why. My habit is GetDate(), but I'm converting to CURRENT_TIMESTAMP as I think it is clearer.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
September 22, 2010 at 10:32 am
I've yet to come across with any reason to not use GetDate() so I'm sticking with GetDate().
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
September 22, 2010 at 10:53 am
CURRENT_TIMESTAMP is the ANSI way to do it..so I guess if you're into such things, go with that.
I use getdate() because I've been using it for roughly a hundred years now, and I probably couldn't break the habit if I tried.
Both commands execute the same internal SQL command, so there is no performance/result difference either way.
September 22, 2010 at 11:00 am
i use getdate() excluseively; like others havre said, it's been in my repitoir for years, and also because of that datatype where a timestamp is not really a timestamp, but it's a rowversion indicator instead, i think the variable current_timestamp is "contaminated", so i avoid using it and stick with getdate() function.
Lowell
September 23, 2010 at 12:58 am
I would like to use getdate() mostly as its having frequent hits than current_timestamp. So far i couldnt see any objections with getdate() and its user friendly.
September 24, 2010 at 9:28 am
I use CURRENT_TIMESTAMP most often, but if I'm feeling lazy about typing, I'll use getdate() because it's fewer characters to type. 🙂
In years past, I'd always used getdate(), but I'd read that CURRENT_TIMESTAMP was supposedly "better", so I've switched over. I'm not certain about the truth in that, but I do like the idea of at least attempting to follow ANSI standards.
December 16, 2010 at 9:08 am
If there's a standard (be it de-facto or formal) way and a non-standard way, and the non-standard give me no advantage I use the standard.
So I use CURRENT_TIMESTAMP.
December 16, 2010 at 10:43 am
I tend to use GetDate() because of habit, but I have to admit, Current_Timestamp is more expressive of what it does, more intuitive to a person who isn't already indoctrinated into one or the other, and it can't hurt to follow the standard. I plan to switch over ... tomorrow ... or maybe ...
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
December 16, 2010 at 12:06 pm
I noticed my devs prefer getdate because they get confused by sqlservers timestamp data type and that same word in current_timestamp !
:blush:
I think that issue should have been fixed by microsoft years ago.
(rename that datatype !)
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
December 16, 2010 at 12:23 pm
I think Microsoft prefers getdate().
CREATE TABLE #test (RowID INT IDENTITY, MyDate DATETIME DEFAULT (CURRENT_TIMESTAMP));
SELECT definition
FROM tempdb.sys.default_constraints
WHERE parent_object_id = object_id('tempdb..#test');
returns:
definition
-----------
(getdate())
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
December 16, 2010 at 9:59 pm
I've checked elapsing time for each of those and got approximate time is less for current_timestamp than getdate().
Is current_timestamp better? i think so....
December 16, 2010 at 10:00 pm
by the by,.... current_timestamp averages 0.21 seconds where as getdate() averages 0.234 seconds.
December 16, 2010 at 10:05 pm
Having been using GETDATE() since I started using SQL Server, that is what I use. However, now that I am using Oracle, I have to change my ways. Will this affect how I code SQL Server, only time will tell.
December 17, 2010 at 1:04 am
vinothraj (12/16/2010)
by the by,.... current_timestamp averages 0.21 seconds where as getdate() averages 0.234 seconds.
I seriously doubt that it takes 0.21 SECONDS to run current_timestamp (or getdate() for that matter) one time.
Doing
declare @i integer, @d datetime
select @i = 1
while @i < 100000 select @d = getdate(), @i = @i + 1
takes about 0.5s. So 1 run would be something like 0.000005s. Well actually less since there is ALOT of extra code in my test besides the date thing.
/T
December 17, 2010 at 1:41 am
I'm working in linked server but you might be working in your own. i just told it based upon the average of ten times but i would like to convey it seems to be current_timestamp conceives less time.
Viewing 15 posts - 1 through 15 (of 52 total)
You must be logged in to reply to this topic. Login to reply