Solved

urgent: vb, convert a string to time format

Posted on 2004-10-07
2
329 Views
Last Modified: 2010-05-02
hi all,

currently i have a string, for example: "20:18:54" , is it a way to convert it into time format/type, so that i can use/insert it into a database where the field is time format. how to write it in vb code? thanks!


mandy
0
Comment
Question by:mandydion
2 Comments
 
LVL 8

Accepted Solution

by:
mladenovicz earned 125 total points
ID: 12247375
If you use INSER INTO to add record to the DB then this string should be "#" & "20:18:54" & "#".
If you use recordset then just adoRecordset("TimeValue") = CDate("20:15:54")
0
 

Expert Comment

by:morchuboo
ID: 12249563
I struggled with the same problem for awhile - its due to the differing ways different microsoft produts handle dates/time
You dont need to convert the string at all - you just need to put in the sql statement correctly:

strsql = "INSERT INTO <table> (<name of field to contain the time>) VALUES ( #" & <variable containing time string> & "#)

Hope it helps
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question