| Author |
Topic  |
|
|
AskSQLTeam
Ask SQLTeam Question
USA
0 Posts |
Posted - 04/25/2001 : 08:56:36
|
Mike writes "Hi! What is the best way to get date(yyyy,mm,dd) using t-sql against sql 2000?
Datepart() returns only a year OR a month OR a day. Am I missing smth?
Thanks" |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
Australia
4970 Posts |
Posted - 04/25/2001 : 09:00:43
|
Hi
GetDate() will get the current date.
To format it, use either the convert function or build a string using datepart.
Damian |
 |
|
|
shane
Starting Member
USA
33 Posts |
Posted - 04/25/2001 : 09:08:21
|
You could do it a couple different ways:
1. convert(varchar,getdate(),102) There are several different date formats you can use with the convert function.
2. convert(varchar,datepart(yy,getdate())) + ' ' + convert(varchar,datepart(mm,getdate())) + ' ' + convert(varchar,datepart(dd,getdate())) Or you parse up the dates manually if you need a proprietary format.
|
 |
|
|
robvolk
SQLTeam MVY/MIA
USA
12325 Posts |
Posted - 04/25/2001 : 09:57:08
|
Another interpretation of the question, "How to get a date in T-SQL?":
Find out what your database's interests are, and talk animatedly about them.
Use subtle flattery, "Wow, that's a really nice stored procedure you got there."
Don't overemphasize or show too much interest in physical hardware and specs, most databases consider that shallow and sexist.
Remember that each database is unique, what works well for one may be a total disaster for another.
Always listen. CPU utilization might only be 7%, but that might be a problem for some databases. Be empathetic.
Don't assume that because everything goes well at first that you'll be granted full permissions to every part of the database. Work your way up to it, and enjoy the journey. Your database will appreciate the attention.
...and always remember, GetDate() will get you a date, but it may not turn out exactly the way you want it.
SELECT ThePerfectWoman FROM AllTheWomenInTheWorld WHERE HerInterests Like Mine AND CurrentMate Is Null AND CurrentlyLives IN ('Yonkers', 'Bondi Beach', 'São Paulo') GROUP BY CASE WHEN AsManyAsWillHaveMe>AsManyAsMyStaminaWillAllow THEN AsManyAsWillHaveMe ELSE AsManyAsMyStaminaWillAllow * 2 END HAVING Max(Libido)>=Mine
I really need to find better things to do with my time 
Edited by - robvolk on 04/25/2001 19:38:08 |
 |
|
|
OwnedByTheMan
Starting Member
Canada
35 Posts |
Posted - 04/25/2001 : 10:44:11
|
...and don't forget to mention the size of your log.
|
 |
|
|
Stevo
Starting Member
USA
8 Posts |
Posted - 04/25/2001 : 21:16:15
|
Be careful about the size of your log actually. I had a server that was offended at my memory space-filling transaction log. After truncating several and backing up others[logs] I realized I needed to simply delete multiple 1 gig+ files on the server. SQL likes it's space, always respect that.
+Stevo |
 |
|
|
nr
SQL Server MVP & SQLTeam MVY
United Kingdom
12531 Posts |
Posted - 04/25/2001 : 22:18:04
|
Don't overemphasize or show too much interest in physical hardware and specs.
Trying to impress a database with too much hardware is either a sign of lack of relational experience (other people) or intelligent planning for future little databases (me).
|
 |
|
|
rrb
SQLTeam Poet Laureate
Australia
1478 Posts |
Posted - 08/07/2002 : 22:55:47
|
quote:
Be careful about the size of your log actually. I had a server that was offended at my memory space-filling transaction log. After truncating several and backing up others[logs] I realized I needed to simply delete multiple 1 gig+ files on the server. SQL likes it's space, always respect that.
Truncating your log? <OUCH>
I'll go for the file deletion option EVERY time
(Aw come on! Someone had to say it!)
Guess I should also add (at this point) that probably not a bad idea to wait a while before the creation of little databases too.
-- I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Edited by - rrb on 08/07/2002 22:59:20 |
 |
|
|
Tim
Starting Member
Australia
392 Posts |
Posted - 09/22/2002 : 23:16:43
|
Which database will be give the best result for getdate() ?
a. SINGLE_USER b. MULTI_USER c. RESTRICTED_USER
---- Nancy Davolio: Best looking chick at Northwind 1992-2000 |
 |
|
| |
Topic  |
|