Jamie Taylor
Jamie Taylor

Reputation: 3530

Need to make my database field a DateTime field currently is set to string

Here's my query

Dim query as String = "Select * from openquery (devbook, 'SELECT wb.arrival_time FROM web_bookings wb ')"

All I need is to convert my arrival_time into a datetime field in the query

Is this possible?

Thanks

Jamie

Upvotes: 0

Views: 102

Answers (1)

Matt Fellows
Matt Fellows

Reputation: 6522

Yes, "SELECT CONVERT (DATETIME, wb.arrival_time, XXX) FROM web_bookings wb"

Where XXX is the format of your string...

Check out http://msdn.microsoft.com/en-us/library/ms187928.aspx for the list of format codes...

So if your string date time was in dd/MM/yyyy format eg 28/12/2008 then your code would be

Dim query as String = "Select * from openquery (devbook, 'SELECT CONVERT (DATETIME, wb.arrival_time, 103) FROM web_bookings wb ')"

Upvotes: 2

Related Questions