Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP and regional date 4

Status
Not open for further replies.

bettyfurr

Technical User
Mar 12, 2002
371
US
Are there any way to check the system for the regional date? I need to vary the table struction/input to the tables depending on Europe type date or US type date.

I have looked at the SYS() numbers and can not determine what I need. Please help!

Betty
 
Hi Betty,

You can tell which date format is in use by:

? SET('DATE')


Jim
 
Betty,

simply go to the Tools Menu, Options, Regional and you can set them as you want

wilfredo
 
bettyfurr,

?RegionalDateSetting()

Function RegionalDateSetting()
#DEFINE LOCALE_IDATE 0x21
LOCAL cReturn, cBuffer, nResult, nUserDefaultLocale, nOrder

Declare INTEGER GetLocaleInfo in kernel32 as GetLocaleInfoA ;
Long,Long,String,Long

DECLARE SHORT GetUserDefaultLCID IN kernel32

cBuffer = SPACE(2)
cReturn = ""
nUserDefaultLocale = GetUserDefaultLCID()
nResult = GetLocaleInfoA(nUserDefaultLocale, LOCALE_IDATE, cBuffer,2)
nOrder = Val(cBuffer)

DO case
CASE nOrder = 0
cReturn = "month/day/year"
CASE nOrder = 1
cReturn = "day/month/year"
CASE nOrder = 2
cReturn = "year/month/day"
ENDCASE

RETURN cReturn
ENDFUNC

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
I believe the question is,
is it possible to idenify from within foxpro, what is the system date followed by OS, so that the same can be set in VFP application at startup ?

I am unable to think, since any VFP attempt will follow the VFPs default set and so to get the systems DATE format has to be using some API. I am short on that :-(

ramani :)
(Subramanian.G)
 
ramani,

Yeah that is what I thought too...I posted the code up above for finding the regional date order. Small modification using Set Date to would allow for this. I should note that I am only returning the short date format system setting in my posted code.

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
ramani,

And then they crossed again, but this time you won. Thanks for the star.

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
Betty,

One important point is that often, users system do not represent their regional setting. Often settings by default are set for US format when the OS is installed. HOwever in the data entry applications users are specific. They dont care that much with OS settings. SO simply following the system date format is not also healthy.

Instead asking the ueer for a choice and saving it somewhere could be a better idea.

:)

ramani :)
(Subramanian.G)
 
I tested slighthaze's code and in the process whatever I changed I thought I will post here. Credit to Slighthhaze.

********************************
sysDate = RegionalDateSetting()
SET DATE (sysDate)
********************************
Function RegionalDateSetting()
#DEFINE LOCALE_IDATE 0x21
LOCAL cReturn, cBuffer, nResult, nUserDefaultLocale, nOrder

Declare INTEGER GetLocaleInfo in kernel32 as GetLocaleInfoA ;
Long,Long,String,Long

DECLARE SHORT GetUserDefaultLCID IN kernel32

cBuffer = SPACE(2)
cReturn = ""
nUserDefaultLocale = GetUserDefaultLCID()
nResult = GetLocaleInfoA(nUserDefaultLocale, LOCALE_IDATE, cBuffer,2)
nOrder = Val(cBuffer)

DO case
CASE nOrder = 0
cReturn = "MDY"
CASE nOrder = 1
cReturn = "DMY"
CASE nOrder = 2
cReturn = "YMD"
ENDCASE

RETURN cReturn
ENDFUNC
**********************************


ramani :)
(Subramanian.G)
 
ramani,

Much more useful. Star.

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top