Solved

urgent: vb, convert a string to time format

Posted on 2004-10-07
2
330 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

820 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