We help IT Professionals succeed at work.
Troubleshooting Question

converting SQL time format for DTPicker field

al4629740
al4629740 asked
on
48 Views
Last Modified: 2020-08-10
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?
Comment
Watch Question

Fabrice LambertConsulting
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Hi,
Try converting to a date:
dtPicker.value = cDate(SQLdata)
Else, can your post you source code ?

Author

Commented:
I still get Type Mismatch error.  Any ideas?

DTPicker = CDate(rec!HourTimeFrom)

Author

Commented:
Ive also tried this below and it yields invalid property value

 AddCYEPHours.DTPicker.Value = CStr(Format$(rec!HourTimeto, "hh:mm AM/PM"))
Martin LissProtect yourself and your loved ones. Stay home for the holidays.
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
What does the data look like?

Author

Commented:
Here is what the data looks like in yellow from the SQL table.  Datatype is time(7)


Martin LissProtect yourself and your loved ones. Stay home for the holidays.
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
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.

Author

Commented:
As I tested it with my value coming from the DB, I get this error.  What's wrong with my syntax?


This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Martin LissProtect yourself and your loved ones. Stay home for the holidays.
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Yes indeed that works.  Thank you.
Martin LissProtect yourself and your loved ones. Stay home for the holidays.
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
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

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions