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)
 DateTime Conversion

Author  Topic 

mauler05
Starting Member

17 Posts

Posted - 2007-10-29 : 11:59:08
Can anyone please let me know how to convert a datetime that is coming as

01/15/2007 09:55:22 AM

to this format

2007-05-10 14:23:34.240 in a VB Script

Thanks....

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2007-10-29 : 12:32:53
declare @myDate as datetime
set @myDate = '01/15/2007 09:55:22 AM'
select convert(varchar(25), @myDate, 120)

In VB Post it in a VB group :)

"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2007-10-29 : 14:23:06
"God does not play dice" -- Albert Einstein
"Einstein, stop telling God what to do! -- Neils Bohr

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-30 : 02:12:33
quote:
Originally posted by mauler05

Can anyone please let me know how to convert a datetime that is coming as

01/15/2007 09:55:22 AM

to this format

2007-05-10 14:23:34.240 in a VB Script

Thanks....



Your expected result is wrong

Madhivanan

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

KenW
Constraint Violating Yak Guru

391 Posts

Posted - 2007-10-30 : 14:29:15
quote:
Originally posted by mauler05

Can anyone please let me know how to convert a datetime that is coming as

01/15/2007 09:55:22 AM

to this format

2007-05-10 14:23:34.240 in a VB Script

Thanks....




Why would you want to convert January 15, 2007 at 9:55AM into May 10, 2007 at 2:23PM? What happened to the rest of the month of January, all of February, all of March, all of April, and the first 9 days of May? What happened between 9:56AM and 2:22PM?

Also, how on earth would you expect to get a VB question answered in a SQL Server 2000 forum? Wouldn't it make more sense to ask in a VB forum instead? There's even one here:

http://www.sqlteam.com/forums/forum.asp?FORUM_ID=18
Go to Top of Page
   

- Advertisement -