March 16, 2010 at 9:54 pm
GilaMonster (3/16/2010)
137 - The inverse of the 'fine structure constant'.
...and the 33rd prime number. Retaining the theme of a, you should probably also use 29 (the 10th prime) a lot too.
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
March 16, 2010 at 10:02 pm
Jeff Moden (3/16/2010)
Heh... I just can't see writing it this way...
DATEADD(DAY, DATEDIFF(DAY, CAST('19000101' AS DATETIME), CURRENT_TIMESTAMP), CAST('19000101' AS DATETIME))
It's not so bad. How about:
SELECT DATEADD(DAY, DATEDIFF(DAY, {d '1900-01-01'}, CURRENT_TIMESTAMP), {d '1900-01-01'})
--or
SELECT DATEADD(DAY, DATEDIFF(DAY, '1900-01-01T00:00:00', CURRENT_TIMESTAMP), '1900-01-01T00:00:00')
Using CAST or CONVERT is not such a bad habit to get into: you have to write dates that way in a function to make it deterministic, for example.
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
March 16, 2010 at 10:03 pm
Paul White (3/16/2010)
GilaMonster (3/16/2010)
137 - The inverse of the 'fine structure constant'....and the 33rd prime number. Retaining the theme of a, you should probably also use 29 (the 10th prime) a lot too.
I use the number 29 a lot... that's the number of hampster poo pellets it takes to fill the flux capacitor on my DBCC TIMEWARP machine.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2010 at 10:04 pm
29 is also my record for the number of pork chops I've had in the air at the same time. I was pretty ticked that day... 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2010 at 10:14 pm
Jeff Moden (3/16/2010)
I assume that by "explicit date" you mean something like '1900-01-01'... and that's not a date either... that's a string that looks like a date. 😛
Aside from using CAST or CONVERT, the following produce a DATETIME directly:
SELECT d = {d '1900-01-01'}, -- Date only at midnight
t = {t '00:00:00.000'}, -- Today at midnight
ts = {ts '1900-01-01 00:00:00.000'} -- Full timestamp
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
March 16, 2010 at 10:39 pm
Paul White (3/16/2010)
Jeff Moden (3/16/2010)
I assume that by "explicit date" you mean something like '1900-01-01'... and that's not a date either... that's a string that looks like a date. 😛Aside from using CAST or CONVERT, the following produce a DATETIME directly:
SELECT d = {d '1900-01-01'}, -- Date only at midnight
t = {t '00:00:00.000'}, -- Today at midnight
ts = {ts '1900-01-01 00:00:00.000'} -- Full timestamp
Very interesting! Apparently, I've been missing out on some good stuff because that works in 2k and 2k5. Keeping in mind that I don't have 2k8, is there a heading in Books Online that I could look under to find out more about such useful shorthand formats such as those above?
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2010 at 10:44 pm
Jeff Moden (3/16/2010)
Very interesting! Apparently, I've been missing out on some good stuff because that works in 2k and 2k5. Keeping in mind that I don't have 2k8, is there a heading in Books Online that I could look under to find out more about such useful shorthand formats such as those above?
Surely is...ODBC Scalar Functions
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
March 16, 2010 at 10:47 pm
I was just getting ready to post that I sussed it...
ODBC timestamp data in Books Online. Was a real SWAG on my part, too! 🙂
Thanks for the link, Paul... I'll take a look.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2010 at 10:53 pm
Paul White (3/16/2010)
Jeff Moden (3/16/2010)
Very interesting! Apparently, I've been missing out on some good stuff because that works in 2k and 2k5. Keeping in mind that I don't have 2k8, is there a heading in Books Online that I could look under to find out more about such useful shorthand formats such as those above?Surely is...ODBC Scalar Functions
Very interesting.
Thanks for the link.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 16, 2010 at 10:54 pm
Jeff Moden (3/16/2010)
Was a real SWAG on my part, too! 🙂
Scientific wild-*** guess?
Special Warfare Action Group?
Silly wild-*** guess?
Stuff we all get?
Smart wild-*** guess?
Software wild-*** guesstimate?
Sold without a guarantee?
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
March 16, 2010 at 11:03 pm
Paul White (3/16/2010)
Jeff Moden (3/16/2010)
Was a real SWAG on my part, too! 🙂Scientific wild-*** guess?
Special Warfare Action Group?
Silly wild-*** guess?
Stuff we all get?
Smart wild-*** guess?
Software wild-*** guesstimate?
Sold without a guarantee?
Nah... I turned on the SWAG lamp so I could see my notes. 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2010 at 11:06 pm
Most of the ODBC Scalar functions have direct equivalents in T-SQL. But... this one is very interesting...
SELECT d = {fn CURRENT_DATE()}
I've gotta see if I can find more goodies like that...
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2010 at 11:18 pm
Jeff Moden (3/16/2010)
Most of the ODBC Scalar functions have direct equivalents in T-SQL. But... this one is very interesting...
SELECT d = {fn CURRENT_DATE()}
Yes. Mentioned it a few posts back - it unfortunately uses string conversion from getdate(), using the undocumented style '23'.
{t ''00:00:00.000} is nice for getting midnight today.
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
March 16, 2010 at 11:33 pm
Now that you mention it, I remember that post. That was before I turned on the SWAG light, though. :hehe:
--Jeff Moden
Change is inevitable... Change for the better is not.
March 17, 2010 at 4:27 am
john.arnott (3/16/2010)
Paul White (3/12/2010)
Jeff Moden (3/12/2010)
We're rootin' for ya!* snigger *
And when you go to London, do you wear a fanny-pack? (Hey. He started it....)
Oooh. Don't say fanny-pack in England. I already made that mistake.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 15 posts - 12,826 through 12,840 (of 66,712 total)
You must be logged in to reply to this topic. Login to reply