Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ambiguous date/date-time constant
Message
From
22/06/2006 08:23:46
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
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:
01130781
Views:
16
Terry,
Borislav already provided a preferred solution. Setting STRICTDATE TO 0 would also do. Fox2x code was somewhat clever to protect itself from ambigiuty of date constant using {1/1/1970}. I can say for sure it's Jan 1:)
I'd like to see it like this if you'd do me that favor:)
DO while not !FEOF( m.lnFHdl)	
  * so each line goes in the memo field which holds > 253 chars
  insert into ergData (DATA) values (FGETS( m.lnFHdl, 8192)) 
EndDo
To me it looks like data was in fact stored as datetime (seconds from base datetime(1970,1,1) and getdate returns the date part of it (fox2x didn't have a datetime). I believe "1146561374" means {^2006/05/02 09:16:14}. If that's right then you could replace getdate() with:
DATETIME(1970,1,1)+val(tickdtg)
Cetin

>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
Reply
Map
View

Click here to load this message in the networking platform