Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to set workstation date time to match SQL Server
Message
From
07/03/2002 09:48:00
 
 
To
07/03/2002 03:36:51
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00629403
Message ID:
00629555
Views:
17
This message has been marked as a message which has helped to the initial question of the thread.
This code will allow you to set local date time from VFP.
FUNCTION API_SetLocalTime
LPARAMETERS ltDateTime

** EXAMPLE ? API_SetLocalTime(DATETIME(1964,10,07,18,0,0))

  IF VARTYPE(ltDateTime) # "T"
    RETURN .F.
  ENDIF

  LOCAL lcString

  lcString = _Num2Word(YEAR(ltDateTime)) + ;
    _Num2Word(MONTH(ltDateTime)) + ;
    _Num2Word(DOW(ltDateTime)) + ;
    _Num2Word(DAY(ltDateTime)) + ;
    _Num2Word(HOUR(ltDateTime)) + ;
    _Num2Word(MINUTE(ltDateTime)) + ;
    _Num2Word(SEC(ltDateTime)) + ;
    _Num2Word(000) + SPAC(24)

  DECLARE SetLocalTime IN Win32Api ;
    STRING lcString

 M.SLT_RETVAL = SetLocalTime(lcString)
 
  RETURN M.SLT_RETVAL

*--------------------------------------
* FUNCTION _Num2Word(lnNumber)
*--------------------------------------
FUNCTION _Num2Word(lnNumber)
  LOCAL lcReturn, lnAscii
  lcReturn = ''
  DO WHILE lnNumber >= 256
    lnAscii = MOD(lnNumber,256)
    lcReturn = lcReturn + CHR(lnAscii)
    lnNumber = INT(lnNumber / 256)
  ENDDO
  lnAscii = lnNumber
  lcReturn = lcReturn + CHR(lnAscii)
  RETURN PADR(lcReturn, 2, CHR(0))
ENDFUNC
*--------------------------------------
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform