How to change date type?  
Author Message
xingyuyoulong





PostPosted: Visual FoxPro General, How to change date type? Top

How to change data type in Foxpro,and what's the function of that

[Note from moderator: clarified date/data confusion as per later post.]



Visual FoxPro2  
 
 
Tracy H





PostPosted: Visual FoxPro General, How to change date type? Top

I just realized you meant DATE type, not DATA type.  If the type is a date you can use DTOC() to change it to a character string.  Or do you mean change from European to American date format or something else   Do you only want to change the display style of the date   Look at tools, options, regional settings in VFP or type 'HELP SET DATE' in the command window to bring up the VFP Help on date formats.

Are you asking about a field or a variable   What is the current data type   What does type() return

 

lcvar = 'Sally'                   && character

TYPE('lcvar')                && Returns 'C'

lcvar = '123'                   && Character string

INT(VAL(lcvar))           && Now an integer

lnvar = 1                         && numeric

TYPE('lnvar')               && Returns 'N'

ALLTRIM(STR(lnvar)) && now a character/string variable

 


 
 
xingyuyoulong





PostPosted: Visual FoxPro General, How to change date type? Top

I just realized you meant DATE type, not DATA type. If the type is a date you can use DTOC() to change it to a character string. Or do you mean change from European to American date format or something else Do you only want to change the display style of the date Look at tools, options, regional settings in VFP or type 'HELP SET DATE' in the command window to bring up the VFP Help on date formats.

Are you asking about a field or a variable What is the current data type What does type() return

lcvar = 'Sally' && character

TYPE('lcvar') && Returns 'C'

lcvar = '123' && Character string

INT(VAL(lcvar)) && Now an integer

lnvar = 1 && numeric

TYPE('lnvar') && Returns 'N'

ALLTRIM(STR(lnvar)) && now a character/string variable

Sorry. I just want to change the display style of the date.

For example,I want to change a number of float type into Double type.

So,which function can realize that.


 
 
Lakshminarayana





PostPosted: Visual FoxPro General, How to change date type? Top

set date to british gives u dd/mm/yy

set date american gives you mm/dd/yy

set date ansi gives you yy.mm.dd

set date german gives you dd.mm.yy

set date italian gives you dd-mm-yy

set date japan gives you yy/mm/dd

set date usa gives you mm-dd-yy

set date mdy gives you mm/dd/yy

set date dmy gives you dd/mm/yy

set date ymd gives yy/mm/dd

the default is american. u can chage it with the above command.

set century on along with the abvoe command display 4 digit year.

i..e with set cent on and set date brit

today's date will be displayed as 24/10/2006

with set cent off

today's date will be displayed as 24/10/06

thanks and regards

(lakshminarayana r)

(chatid)



 
 
AndyKr





PostPosted: Visual FoxPro General, How to change date type? Top

>> For example,I want to change a number of float type into Double type.

In VFP 9.0 use the CAST() function.

There is no single function for doing it in earlier versions, but you can define a cursor with the correct data type and then insert the data into the correct columns using the individual transformation functions (INT(), VAL(), STR() etc)