Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change system date and time
Message
From
15/06/2012 15:34:31
 
 
To
15/06/2012 15:13:37
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Miscellaneous
Thread ID:
01546116
Message ID:
01546117
Views:
59
>Hi friends:
>
>I want to change date and/or time wihin VFP. I tried using "RUN (NEWDATE)" but it doesn't work. I tried searching on the web and I found just a few API based funcitons but they haven't worked either. Perhaps any of you knows the magical solution.
>
>Thank you
>
> Hector

First you need to create a system time:
PROCEDURE CreateSystemTime
LPARAMETERS ttTimeStamp
#DEFINE WORD 2
#DEFINE LDWORD 8
IF VARTYPE(ttTimeStamp) # "T"
	ttTimeStamp = DATETIME()
ENDIF
LOCAL	lcResult, ;
		lnYear, ;
		lnMonth, ;
		lnDow, ;
		lnDay, ;
		lnHour, ;
		lnMinute, ;
		lnSec
*
lnYear = YEAR(ttTimeStamp)
lnMonth = MONTH(ttTimeStamp)
lnDow = DOW(ttTimeStamp) - 1
lnDay = DAY(ttTimeStamp)
lnHour = HOUR(ttTimeStamp)
lnMinute = MINUTE(ttTimeStamp)
lnSec = SEC(ttTimeStamp)
*
WITH THIS
	lcResult = .IntegerToString(lnYear, WORD) + ;
				.IntegerToString(lnMonth, WORD) + ;
				.IntegerToString(lnDow, WORD) + ;
				.IntegerToString(lnDay, WORD) + ;
				.IntegerToString(lnHour, WORD) + ;
				.IntegerToString(lnMinute, WORD) + ;
				.IntegerToString(lnSec, WORD) + ;
				.IntegerToString(0, WORD)
ENDWITH
RETURN lcResult
Then you can update the time:
ltDateTime = DATETIME(2000,1,1,12,00,00)
lsSysTime = CreateSystemTime(ltDateTime)
DECLARE INTEGER SetLocalTime IN Kernel32 STRING
SetLocalTime(lsSysTime)
I used to do that after checking the time on the database server and then "syncronize" the time on the local machine.
Christian Isberner
Software Consultant
Previous
Reply
Map
View

Click here to load this message in the networking platform