×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Need specific DateTime format

Need specific DateTime format

Need specific DateTime format

(OP)
How to format DateTime value like this:
'29.01.2008. 23:56'

Thanks in advance!

RE: Need specific DateTime format

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: How to get the best answers before posting.

RE: Need specific DateTime format

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?

----signature below----
I'm pushing an elephant up the stairs

My Crummy Web Page

RE: Need specific DateTime format

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: How to get the best answers before posting.

RE: Need specific DateTime format

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 ;)

----signature below----
I'm pushing an elephant up the stairs

My Crummy Web Page

RE: Need specific DateTime format

Quote (AlexCuse):

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: How to get the best answers before posting.

RE: Need specific DateTime format

Quote (Alex):

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: How to get the best answers before posting.

RE: Need specific DateTime format

(OP)
HarleyQuinn, your solution is perfect!
CODE
SELECT (CONVERT(VARCHAR(10), GETDATE(), 104)) + '. ' + (CONVERT(VARCHAR(5), GETDATE(), 8))

Thanks!

RE: Need specific DateTime format

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: How to get the best answers before posting.

RE: Need specific DateTime format

Me thinks its worth a little recognition :)

----signature below----
I'm pushing an elephant up the stairs

My Crummy Web Page

RE: Need specific DateTime format

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: How to get the best answers before posting.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close