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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to insert time filed into sql table?

Status
Not open for further replies.

Niki_S

Programmer
Jun 4, 2021
232
0
0
LK
I have a sql field as below,


timein (time (7) )

And now I want to isert data to that field using foxpro. For that I have a filed in foxpro as 'timein'.

How can I arrange my foxpro field to insert time field?

Thank you.
 
What do you mean by a "sql field"? Sql is not a data type.

And what is timein (time (7) )? I don't recognise that as VFP syntax?

In general, if you want to insert a time into a VFP table, you use the DateTime data type. Unlike some other languages, there is no separate Time data type. You can of course also store times as character fields, for example, "02:50" or "19:30". But that would not enable you to directly perform arithmetic or to compare two times.

You can also use TTOC() to extract the time element from a datetime.

Does that help at all? If not, you will need to clarify your question.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I already used TTOC(). But I want to get only the time. Can I get only the time ?
 
If you pass 2 as the second parameter of TTOC(), that will give you just the time element. So if ltNow contains the current date and time (e.g. 22/08/22 09:33), then [tt]TTOC(ltNow, 2[/tt]) will return "09:33" as a character string.

If you also want to show the number of seconds, SET SECONDS ON. If you want to show an AM/PM indicator, SET HOURS TO 12.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi

Since the VARTYPE(TIME()) = "C" and the TIME() has 8 characters , you may simply code

Code:
create cursor ... (cTimeIn C(8) ...)

insert into cursor ... values(Time() ...)

hth

MarK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top