Mike Yearwood
Toronto, Ontario, Canada
Information générale
Catégorie:
Codage, syntaxe et commandes
>Hi all
>
>Does anyone have program that can convert / format dates / datetimes like Excel does?
>
>I know I can ...
>
>
>LPARAMETERS tuDateOrTime
>RETURN ;
> RIGHT("00"+ALLTRIM(STR(MONTH(m.tuDateOrTime))),2)+"/"+;
> RIGHT("00"+ALLTRIM(STR(DAY(m.tuDateOrTime))),2)+"/"+;
> ALLTRIM(STR(YEAR(m.tuDateOrTime)))
>
>
>But something like transform(date(),"MMM-DD-YYYY") to get Feb 10, 2003 seems easier than the current options.
>
>TIA
One of the alternatives is to use Excel formatting directly. Formatting in Excel is more flexible and more expanded than in VFP. Below is an example.
You can even use unusual format like "mm-mmm-mmmm" to display month in all formats.
?iExcelFormat(date(), "dd-mmm-yyyy")
Procedure iExcelFormat
lParameter pdate, pcformat
local objExcel, retval
objExcel= CREATEOBJECT("Excel.Application")
with ObjExcel
.DisplayAlerts = .f.
.Workbooks.add()
with .Range("a1")
.Value=pdate
.NumberFormat = pcformat
retval=.Text
endwith
endwith
objExcel.quit
objexcel=.null.
release objexcel
return retval
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement