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

Trouble Writing date-time Expression 1

Status
Not open for further replies.

xBaseDude

MIS
Jan 31, 2002
357
US
Amigos..

I'm having some trouble with a date time expression.

I'm looking to get the date/time back as 12345.1234

Here is an example of what I'm trying to do....

= ADIR(laFilesInDir, '*.jbf')
*
FOR x = 1 TO ALEN(laFilesInDir)/5
z = [({^] + DTOC(laFilesInDir(1,3))+ [t] + laFilesInDir(1,4) + [})]
vardt = EVALUATE(z)
x=(TTOD(vardt)-{12/30/1899})+HOUR(vardt)/24+MINUTE (vardt)/24/60+SEC(vardt)/24/60/60
?x
ENDFOR

*---------------------

vardt = EVALUATE(z) is containing illegal characters.

This is VFP70 and I think case sensitivity of "t" might be an issue.

Any ideas how I need to assemble and EVAL my expression?

TIA - Wayne


sig_jugler.gif
...all this and tap dancing too!
 
xBaseDude

I'm looking to get the date/time back as 12345.1234

Can you explain what date format this is? It looks unfamiliar.



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Wayne,
Try:
Code:
z = [{^] + STUFF(STUFF(DTOS(laDir(1,3)),5,0,"/"),8,0,"/")+ [ ] + laDir(1,4) + [}]
You don't need the "t", can't include the "()"s and you've got use the YYYY/MM/DD format for the ^ (non-ambiguous) date format.

Rick
 
Thanx Rick!

Mike, I'll explain when I get back to *my* machine.

Regards - Wayne

sig_jugler.gif
...all this and tap dancing too!
 
Rick;

You don't need the "t", can't include the "()"s and you've got use the YYYY/MM/DD format for the ^ (non-ambiguous) date format.

Gosh, wasn't too far off was I !!! [g]

Thank-You very much for your fine coding example. "Stuff" is a new foxpro command for me. I am more familiar with STRTRANS. But hey! It works!

The completed coding sample goes something like this...

SET DEFAULT TO a:

= ADIR(laDir, '*.*')
*
FOR x = 1 TO ALEN(laDir)/5
z = [{^] + STUFF(STUFF(DTOS(laDir(1,3)),5,0,"/"),8,0,"/")+ SPACE(1) + laDir(1,4) + [}]
vardt = EVALUATE(z) && you still need to EVAL
? vardt
x=(TTOD(vardt)-{^1899/12/30})+HOUR(vardt)/24+MINUTE(vardt)/24/60+SEC(vardt)/24/60/60 && don't forget the "^" symbol in the 1899/12/30 base line date.
?x
ENDFOR

********

Mike;

Can you explain what date format this is? It looks unfamiliar.

At the risk of being corrected, I believe it is how Windows stores dates and times. I have caused confusion in the forum here by refering to it as the "date-time value". Most everyone I've "talked" to here, sees the date time value as this format...."11/08/2002 09:01:22 AM", so I believe my usage of the word is incorrect. iow I don't have the name of this numeric format to give you.

Perhaps someone could jump in and educate us both...

I can tell you this with a fair degree of certainty, the Integer part of the number refers to the number of days since the "base line" date of 1899/12/30.

The remainder of the value (the numbers to the right of the decimal) represent the value of time to the seconds precision. However, I am unclear on how the mathematical formula behind it works. At first I thought it was a "percentage" of the total number of seconds in a 24 hour period. iow 24*60*60 = 86400, but again I believe I am incorrect in my assumption. However when the appropriate foxpro commands are applied to it's value, it returns the correct hours, minutes,seconds.

...very open to someone expanding on this for us...jump in here...

So the value of "11/08/2002 09:01:22 AM" can also be expressed as 37568.3759. I think the potential savings in space and simplicity of use in queries makes this a very useful piece of data.

You now know as much about it as I do.

Regards - Wayne


sig_jugler.gif
...all this and tap dancing too!
 

Wayne

Thank you for the explanation. The only further thing I can add to this is, if I copy "11/08/2002 09:01:22 AM" to an Excel sheet and change to format of the cell to "Selection.NumberFormat = "0.00"", I get the date changed to 37568.38. I can see that if you where to recieve data in that fashion for an Excel sheet, you would need to convert it to a proper date format.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top