Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ambiguous date/date-time constant
Message
From
22/06/2006 10:07:39
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
22/06/2006 09:31:36
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
FoxPro Dos
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01130765
Message ID:
01130807
Views:
14
And strictdate format in VFP:) {^1970/1/1} would fail I mean under fox2x.
Cetin

>The option of using date() with three parameters was introduced in version 6.
>
>>
>>funct getdate(secs)
>>   xdays = int(secs/secsday)
>>   xdate = {^1970-01-01} + xdays
>>return xdate
>>
>>
>>I am not sure for DOS but I love this VFP option:
>>
>>funct getdate(secs)
>>   xdays = int(secs/secsday)
>>   xdate = DATE(1970,1,1) + xdays
>>return xdate
>>
>>
>>
>>>Hi People
>>>
>>>I've been getting out some bugs from an old FPD system (not mine). This prog reads in a text file, comma delim, and creates a FPD table from it.
>>>
>>>Originally it appended data from the source file:
>>>
>>>
>>>create table ergdata (data c(253))
>>>...
>>>tfile = thisdir + cfile && not MY code - ugh!
>>>sele ergdata
>>>append from (tfile) type sdf
>>>
>>>
>>>thus importing each line of the file into the only field of the "reception" table, ERGDATA.
>>>
>>>but I discovered that some files have >253 chars in a line (esp. in the top line - 1st record - where the column headings are. So it was truncating the first line and losing out on subsequent field names (this daft code later reads the first line and generates a table with one field for each column header. The code is so labrythine that I don't want to go into changing how this all works - very arcane!
>>>
>>>So I changed it to a memo field to hold the lines:
>>>
>>>
>>>Create Table ERGData (data m)
>>>
>>>
>>>and my code, to replace "append from (tfile) type sdf" is:
>>>
>>>
>>>lnFHdl	     = FOPEN( tfile)
>>>llFEOF	     = .F.
>>>DO while not llFEOF	
>>>  lcTextLine  = FGETS( lnFHdl, 400)
>>>  If FEOF( lnFHdl)	
>>>      llFEOF  = .T.
>>>  Else
>>>      Append Blank
>>>      Replace DATA with lcTextLine  && so each line goes in the memo field which holds > 253 chars
>>>  EndIf
>>>EndDo
>>>
>>>
>>>Now, having got rid of the bug (which was its inability to deal with slightly different arrangement of the import fields) and the program continuing to the end, I get an obscure error in the function GetDate (again - not mine) on the commented line below:
>>>
>>>
>>>funct getdate
>>>param secs
>>>xdays=int(secs/secsday)
>>>xdate={01/01/1970}+xdays              && error here
>>>return xdate
>>>
>>>
>>>It's invoked by:
>>>
>>>getdate(val(tickdtg)) && tickdtg being the field holding the date string
>>>
>>>The date field comes from each line read from the reception table memo field which is of the form emboldened below:
>>>
>>>... 3,0,2,0,1146561374,1,1,18
>>>
>>>and the error message is:
>>>
>>>
>>>Ambiguous date/date-time constant. Use the format:
>>>    {^yyyy-mm-dd[,][hh[:mm[:ss]] [alp]]}
>>>
>>>
>>>Now, I know that the import file has not been "converted" by the Append ... type SDF command
>>>
>>>and Help says:
>>>
>>>"Effective conversion of date data from SDF files to Visual FoxPro tables requires data to be stored in YYYYMMDD format.
>>>
>>>If date information is stored in ambiguous formats, you should map the date column to a character column of appropriate width so you can inspect the value then apply the correct conversion routine to create correctly formatted date data."
>>>
>>>Whatever the last paragraph means! Presumably a date in the form 1146561374 gets converted in some form to be compatible cos in this form it's meaningless to me.
>>>
>>>Anyone any ideas how I can get round this predicament?
>>>
>>>'ppreciate it
>>>
>>>Terry
>>>
>>>NOTE I'm running this FPD prog from VFP so I can use its power, debugger, etc.
Ç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