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
>>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
>> 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
>>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.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)