Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 select getdate() formattttt?????

Author  Topic 

bilencekic
Posting Yak Master

121 Posts

Posted - 2005-07-25 : 10:20:00
When i write that code select getdate()
2005-07-25 17:18:28.210
but i want it like
25-07-2005 17:18:28.210

is there any code to format or conver getdate function??
like
select getdate(dd.mm.yyyy) :)
helpp

MCP (70-229)

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-25 : 10:24:33
Do this in your presentation layer
What is your Front end application?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-07-25 : 10:25:32
Select Convert(Varchar,Getdate(),103)

for other formats you Search for Convert on BOL...

Complicated things can be done by simple thinking
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-07-25 : 10:25:42
look up convert function in BOL = Books OnLine = sql server help.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-07-25 : 10:26:19
by 10 seconds

Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-25 : 10:27:44
>>Select Convert(Varchar,Getdate(),103)
That should be 104

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-07-25 : 10:32:14
Right ...
Go to Top of Page

bilencekic
Posting Yak Master

121 Posts

Posted - 2005-07-25 : 10:44:52
thx guys :)


MCP (70-229)
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2005-07-25 : 11:38:52
Sorry, mad had it right in the first response. Quit fiddling with dates on SQL SERVER, and let the presentation layer do it!

*need more coffee*
SELECT * FROM Users WHERE CLUE > 0
(0 row(s) affected)
Go to Top of Page

bilencekic
Posting Yak Master

121 Posts

Posted - 2005-07-26 : 15:04:58
donatwork what are u triing to say?
presentation layer cant do it.
it must be on sql. and i solved problem. user your clue on other works

MCP (70-229)
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-07-26 : 15:09:26
Your presentation layer cannot format date values? What are you using to present your data, notepad ?


- Jeff
Go to Top of Page

bilencekic
Posting Yak Master

121 Posts

Posted - 2005-07-26 : 15:13:33
arggggg.
no i have to make calculations on sql to fill datagrid
and i dont want to use vs.net to do it.
i want to do other alternatesssss and fixed it.
as you have ages , i have projects more than it.

MCP (70-229)
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-07-26 : 15:48:31
quote:
Originally posted by jsmith8858

Your presentation layer cannot format date values? What are you using to present your data, notepad ?


- Jeff



Why would you post something like this? Why insult the guy for no reason?



-ec
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-07-26 : 15:55:37
quote:
Originally posted by eyechart

quote:
Originally posted by jsmith8858

Your presentation layer cannot format date values? What are you using to present your data, notepad ?


- Jeff



Why would you post something like this? Why insult the guy for no reason?

-ec



Of all the questionable posts over the years here at sqlteam, you pick my joke about notepad as an "insult"?

- Jeff
Go to Top of Page

bilencekic
Posting Yak Master

121 Posts

Posted - 2005-07-26 : 16:00:30
what a nice joke

MS BLESS US
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-07-26 : 16:11:59
You first said you CAN'T do your formatting at the client; but now we have determined that you simply don't want to.

Keep in mind that instead of returning dates to your datagrid, you are now returning strings formatted to look like dates. So if you need to sort or compare your dates using the features of DataGrids, they will not work properly unless you first convert the values back to the original date values. This is a big reason why, in SQL Server, you should just return VALUES back to the client and let the client do the formatting, and let your datagrids contain the values and do the formatting for you.

DataGrid's have full formatting capabilities to format dates any way you need, and it is much more flexible than using CONVERT() in T-SQL. T-SQL is not a language designed for data formatting, and as such your database layer should not do formatting. It is almost always easier, more efficient, and more flexible to have the client do this work.

Often, people say they don't have time to do it right, they just need to get it done. And it invariably ends up taking longer and being a lot more work in the long run doing things the "quick" way and not taking the time use best practices.

edit: Though I will add that it is a little complicated to format columns on a windows forms DataGrid; it is much easier in ASP.NET. This link http://support.microsoft.com/default.aspx?scid=KB;EN-US;318581 has some info for you.

- Jeff
Go to Top of Page

bilencekic
Posting Yak Master

121 Posts

Posted - 2005-07-26 : 16:21:50
SET DATEFORMAT dmy

datetime column formating is looks okay now. and works in datediff(day,satrtdate,enddate)
now everyting is okay :)
just be ok.

MS BLESS US
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-07-26 : 16:55:17
Jeff,

I prefer to answer people's questions. It is fine to point out that there might be other, better methods to accomplish something, but it is more important to answer the question asked.

Obviously, bil is not a native english speaker. Do you really expect him to understand your joke?


-ec
Go to Top of Page

bilencekic
Posting Yak Master

121 Posts

Posted - 2005-07-26 : 17:06:46
:) thx eyechart my native lang is turkish
my english is not very well :) sorry

MS BLESS US
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-07-26 : 18:05:36
quote:
Originally posted by eyechart

Jeff,

I prefer to answer people's questions. It is fine to point out that there might be other, better methods to accomplish something, but it is more important to answer the question asked.

Obviously, bil is not a native english speaker. Do you really expect him to understand your joke?

-ec



I am sorry to offend you as well. I was only trying to insult him alone, and not others in the forum, with my nasty message.

He said his presentation layer could not do the formatting. I doubted that and implied that just about the only "presentation" tool that cannot format dates for you would be something like notepad.

And guess what?

My mean, horrible insult actually resulted in a reply in which he indicated what the actual tool is. And then, somehow, we both got past the nasty name calling that I instigated, and I was able to use the information from his reply to somehow actually provide an answer, a link, and some more information for him, despite my honest attempts to simply cause trouble and not help in any way.

- Jeff
Go to Top of Page

bilencekic
Posting Yak Master

121 Posts

Posted - 2005-07-26 : 18:09:42
:) lol stop
forgot my questions :)) these messegaes are off topic


MS BLESS US
Go to Top of Page
    Next Page

- Advertisement -