Link to home
Start Free TrialLog in
Avatar of al4629740
al4629740Flag for United States of America

asked on

converting SQL time format for DTPicker field

I have a column in an SQL table with datatype time(7).  When I try to place that value into a VB6 DTPicker control, however it doesn't take it.  What format do I need to convert to in order to get it into the VB6 form field and how do I convert it in sql properly?
Avatar of Fabrice Lambert
Fabrice Lambert
Flag of France image

Hi,
Try converting to a date:
dtPicker.value = cDate(SQLdata)

Open in new window

Else, can your post you source code ?
Avatar of al4629740

ASKER

I still get Type Mismatch error.  Any ideas?

DTPicker = CDate(rec!HourTimeFrom)

Open in new window

Ive also tried this below and it yields invalid property value

 AddCYEPHours.DTPicker.Value = CStr(Format$(rec!HourTimeto, "hh:mm AM/PM"))

Open in new window

What does the data look like?
Here is what the data looks like in yellow from the SQL table.  Datatype is time(7)

User generated image
Do you have Dtpicker set up to show time? if so this seems to work.
Const S = "09:00:00.0000000"
DTPicker1.Value = Left(S, 8)

Open in new window

You would of course not use the Const but rather your variable.
As I tested it with my value coming from the DB, I get this error.  What's wrong with my syntax?

User generated image
ASKER CERTIFIED SOLUTION
Avatar of al4629740
al4629740
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes indeed that works.  Thank you.
You’re welcome and I’m glad I was able to help.

If you expand the “Full Biography" section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange Most Valuable Expert (MVE) 2015, 2017
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2019
              Experts Exchange Top Expert VBA 2018, 2019
              Experts Exchange Distinguished Expert in Excel 2018