Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Datetime gotcha
Message
From
29/11/1999 12:16:31
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
29/11/1999 11:56:15
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00296388
Message ID:
00296413
Views:
17
>>
lparameters tc2File, tnShift
>>if type("tnShift") # "N"
>>  tnShift = 0
>>endif
>>lcFrom1 = getfile("DBF","Info dosyasi ?")
>>lcFrom2 = getfile("DBF","Velocity dosyasi ?")
>>select ;
>>	dtot(a.date_b) + ;
>>		int(a.tb)*3600 + ;
>>		((a.tb - int(a.tb)) * 100 * 60 ) ;
>>		AS tDT, ;
>>	B.Vel ;
>>	from (lcFrom1) a, (lcFrom2) b ;
>>	where  a.cm_code = b.cm_CODE ;
>>	into table (tc2File)
>>replace all tdt with ( tdt+(recno()-1)*3600 ) + tnShift
>>
>>Run the code and browsed the tables proudly again showing them all data now had tnShift mins shift and could be joined easily. I forgot one little point. VFP stores datetime as real values not as YYYYMMDD... as in date type :( When I did the SQL (which I thought a child could do too) I got 0 records !
>>
>>Only moving "+ tnShift" into SQL corrected the problem (before "as tdt").
>>Cetin
>
>Actually, datetime() stores the date as integer Julian date (first 4 bytes) and milliseconds after midnight (other 4 bytes), though in operation it treats them as seconds. So you should be adding 3600 to what was already in there, or whatever other process you use to get around this - even if it includes replacing all datetimes with ctot(ttoc(datetimefield)), which would round it to whole seconds. Actually, there are a thousand different datetimes which have the same ttoc() representation...


So you say :
If I have {^1997/01/16 16:00:00} in tdt,

replace tdt with tdt + 30*60

wouldn't make it equal to :
{^1997/01/16 16:30:00}

but this would :
replace tdt with ctot(ttoc(tdt+ 30*60)) ?

Well but wouldn't this depend on some "set".
If I could get milliseconds from a datetime this would make sense.

Or whenever doing an SQL do not join on datetime() field directly w/o a conversion to ttoc(tdt,1) :)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform