Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time from database is converted to datetime 1

Status
Not open for further replies.

DirkVFP

Programmer
Aug 25, 2005
57
NL
Hello all,

Whenever I do a select from a table from a column defined as time, all values from that column in my foxpro cursor have a date in front of it.

As seen in my database: "11:08:55"
As seen in my foxpro cursor: "30-12-99 11:08:55"

So it seems foxpro just places this date in front of it.
Since I use a listbox with the rowsource set to my cursor, I have no means of editting the time column. I just want the time to be displayed.

How can I make foxpro get the time only, without any date?
My guess is it's a SET option, but I have no idea which one to use.
 

Hi Dirk,

Whenever I do a select from a table from a column defined as time, ...

What database are you using? VFP doesn't have a time data type (only datetime). Same applies to most back ends, as far as I know.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
First off, thanks for the quick replies!

TTOC(YourDateTimeField,2)

Regards,
Jim

Jim, I can't do any edits on the data, it is being placed in a listbox directly from a cursor. So I need to deal with this at the root (= when my data enters the Foxpro domain)

Mike, I'm using a PostgreSQL 8.0 database.

 

Dirk,

How are you accessing the data from your Postgres database? Are you using a remote view, or SQL pass-through?

Either way, you need to convert the Time field to a Character field. With a remote view, you can change the data type using DBSETPROP(). If you are using SPT, you need to use the CAST() function, or its equivalent, in your SELECT command.

If you can provide that information, I can talk you through the steps.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

I am using SQL pass-through, and you mentioned a CAST() function which made me realize I use casts all the time, but this time I seem to have forgotten completely about them! (Maybe since I've never worked with time in my dbases before).

Anyways, the solution is real clear now:
Code:
select time::varchar(8) from messages
or 
select cast(time as varchar(8)) from messages

These both work fine!

Mike, thanks alot for your help again!
I wish I could teach you new things for a change, but that won't happen soon I presume ;)

Dirk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top