Solved

urgent: vb, convert a string to time format

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now