Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need specific DateTime format

Status
Not open for further replies.

Delphard

Programmer
Jul 22, 2004
144
RS
How to format DateTime value like this:
'29.01.2008. 23:56'

Thanks in advance!
 
I'd have a look at CONVERT()

Hope this helps.

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
To the best of my (limited) knowledge, you can't get the dots with CONVERT(), so you'd need to use replace as well.

But more importantly, are you trying to do this in T-SQL or VBScript?

[small]----signature below----[/small]
I'm pushing an elephant up the stairs

My Crummy Web Page
 
Alex,

Could you do the dots using something like
Code:
SELECT (CONVERT(VARCHAR(10), GETDATE(), 104)) + '. ' + (CONVERT(VARCHAR(5), GETDATE(), 8))
I've not got SQLServer to test this on though (just been looking at BOL) so if that's way off I'm sorry [blush]



HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Yeah, that works. I was hoping there was a format you could use REPLACE() on to get everything in one shot, but there seems to be a problem with the 131 format (it gives me some screwy date in 1429 !)

Of course if it has to be done in VBScript it was all for nothing ;)

[small]----signature below----[/small]
I'm pushing an elephant up the stairs

My Crummy Web Page
 
AlexCuse said:
problem with the 131 format (it gives me some screwy date in 1429 !)
Oh er! [wink]

Got to agree though, if it's VBS then it's time wasted [wink]

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Alex said:
Besides, its' never time wasted

Well, I got to do this instead of work for a bit [wink]

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
HarleyQuinn, your solution is perfect!
CODE
SELECT (CONVERT(VARCHAR(10), GETDATE(), 104)) + '. ' + (CONVERT(VARCHAR(5), GETDATE(), 8))

Thanks!
 
You're welcome, glad I could help [smile]

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Cheers Alex [smile]

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top