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

2.6 - How can I convert a date time into an integer?

Status
Not open for further replies.

marcela24

Programmer
Feb 17, 2003
72
0
0
NL
Iam trying to create an index in Fox Pro. I found out that a good solution would be: create an index converting the actual sysdate to an integer. But I can´t find any function that does it. Can anyone help with this problem?
Do anybody know how can i convert this or how can I create an index (that never repeates)?
Tks.
 
Hi,

Look for sys(3) and sys(2015) in the help file, maybe that's what you need.
 
Marcela,
If you only need one record per day, look at:
?dtoc(date(),1)
?dtos(date())

or even:
? SYS(1) && convert it to readable ? SYS(10,VAL(SYS(1)))

These all create a character string that increases as the date increases.

If you need more than one record per day, then sys(3) and sys(2015) are more appropriate, but even they may ne4ed to be "fixed" in a multi-user application.

Rick

Rick

 
Thanks guys! I'll try to use the sys(3) or sys(2015) because I want to have more than one record per day. I have a multi-user app but I'll try to use it anyway.
 
Marcelo,
try sys(11,date())*100000+sys(2).
May be duplicate keys daily differ adding 1.
Advantage is datetime meaning of the key, reversing if needed.
Tesar
 

Marcela,

Here is 2 more options for you:

?INT(VAL(DTOS(DATE())+STRTRAN(TIME(),":","")))

Or this could be more precise and, possibly, faster:

?INT(VAL(DTOS(DATE()))*10^9+SECONDS()*10^3)


Stella
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top