On 6/21/06, MB Software Solutions <[EMAIL PROTECTED]> wrote:
>
Oh I like that too, mind you, but there are times where I'd like to see
what I've worked on last.


This'll work:

SELECT PADr(ObjName,20) as classname, ;
stamp2dt(timestamp) as ts ;
FROM "C:\Program Files\Microsoft Visual FoxPro 8\Gallery\_gallery.vcx" ;
WHERE NOT EMPTY(timestamp) ;
ORDER BY ts desc

where stamp2dt.prg is:

* Stamp2DT - .SCX/.VCX timestamp to datetime variable
* Copyright (c) 1996, Ted Roche
parameter tnStamp
local ltStamp && datetime return value
local lcDateSet  && Stores the initial SET("DATE")

#DEFINE SecondsMask 31
#DEFINE MinutesMask 2016
#DEFINE HoursMask   63488
#DEFINE DaysMask    2031616
#DEFINE MonthsMask  31457280
#DEFINE YearsMask   1040187392

#DEFINE SecondsOffset 1  && Note this is a LEFT shift, not RIGHT
#DEFINE MinutesOffset 5
#DEFINE HoursOffset   11
#DEFINE DaysOffset    16
#DEFINE MonthsOffset  21
#DEFINE YearsOffset   25

#DEFINE t2Month str(bitrshift(bitand(tnStamp,MONTHSMASK), ;
                             MONTHSOFFSET),2)
#DEFINE t2Day   str(bitrshift(bitand(tnStamp,DAYSMASK), ;
                                    DAYSOFFSET),2)
#DEFINE t2Year  str(1980+bitrshift(bitand(tnStamp,YEARSMASK), ;
                                  YEARSOFFSET),4)

#DEFINE t2Time  str(bitrshift(bitand(tnStamp,HOURSMASK), ;
                             HOURSOFFSET),2) + ":" + ;
               str(bitrshift(bitand(tnStamp,MINUTESMASK), ;
                             MINUTESOFFSET),2) + ":" + ;
               str(bitlshift(bitand(tnStamp,SECONDSMASK), ;
                             SECONDSOFFSET),2)

* This formula must test and process using the existing
* SET("DATE"), rather than setting and re-setting it.
* If we were to change date formats in this UDF, even with
* the intention of restoring them upon return from the
* function, displayed dates within a browse are refreshed,
* causing all sorts of havoc. Therefore, if you must code
* for three different date formats, you must use a case
* statement here, rather than an arbitrary SET command.

lcDateSet = SET("DATE")

do case
 case INLIST(lcDateSet,"USA","AMERICAN","MDY")
   ltStamp = ctot(t2Month + "/" + t2Day + "/" + t2Year + ;
                  " " + t2Time)

 case INLIST(lcDateSet,"ANSI","JAPAN","YMD")
   ltStamp = ctot(t2Year + "/" + t2Month + "/" + t2Day + ;
                  " " + t2Time)

 case INLIST(lcDateSet,"BRITISH","FRENCH","GERMAN", ;
                       "ITALIAN","DMY")
   ltStamp = ctot(t2Day + "/" + t2Month + "/" + t2Year + ;
                  " " + t2Time)

 otherwise
   ltStamp = dtot({})
endcase

return ltStamp

* Of course, that last bit of code can be rewritten at this point to
use DATETIME() with parameters but this was likely written for VFP 3.

--
Ted Roche
Ted Roche & Associates, LLC
http://www.tedroche.com


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to