Microsoft KB Archive/190265

= How To Find the Day that Daylight Saving Time Occurs =

Article ID: 190265

Article Last Modified on 1/23/2007

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.6 Standard Edition
 * Microsoft FoxPro 2.6a Standard Edition
 * Microsoft FoxPro 2.5b for Macintosh
 * Microsoft Visual FoxPro 2.5c for Macintosh
 * Microsoft FoxPro 2.6a Professional Edition for Macintosh
 * Microsoft Visual FoxPro 3.0 for Macintosh

-



This article was previously published under Q190265



SUMMARY
Under legislation enacted in 1986, Daylight Saving time in the United States (U.S.) begins at 2 A.M. on the first Sunday of April and ends at 2 A.M. on the last Sunday of October. The sample code in the MORE INFORMATION section determines what day in April the first Sunday occurs and on and what day in October the last Sunday occurs for each year.



Sample Code
* Note that bdate and edate are assigned the first day of April and the * last day of October in this example. You would want to change these * variables to be equal to the DATE function in a real situation.

CLEAR

IF "6.00"$VERSION(1) oldstrictdate = SET("STRICTDATE") SET STRICTDATE TO 0 ENDIF

bdate = {04/01/98} && Change year to check other dates, edate = {10/31/98} && use the DATE function for real time. y = "" IF MONTH(bdate) = 4 AND DAY(bdate) < 8 && First week of April. * Need first day of month and current year, change to DATE. bsavings = CTOD('04/01/' + ALLTRIM(STR(YEAR(BDATE)))) =getnum(CDOW(bsavings)) && Get number to add to first day of April. ? "Daylight Saving Time starts on Sunday - " ?? bsavings + VAL(SUBSTR(y,1,1)) ? "The first day of April is: " ?? CDOW(bsavings) ENDIF

IF MONTH(edate) = 10 AND DAY(edate) > 24 && Last week of October. * Need last day of month and current year, change to DATE. esavings = CTOD('10/31/' + ALLTRIM(STR(YEAR(EDATE)))) =getnum(CDOW(esavings)) && Get number to subtract from 10/31. ? "Daylight Saving Time ends on Sunday - " ?? esavings - VAL(SUBSTR(y,2,1)) ? "The last day of October is: " ?? CDOW(esavings) ENDIF

IF "6.00"$VERSION(1) SET STRICTDATE TO &oldstrictdate ENDIF

PROCEDURE getnum PARAMETER dayvar

DO CASE CASE dayvar = "Sunday" y='00' CASE dayvar = "Monday" y='61' CASE dayvar = "Tuesday" y='52' CASE dayvar = "Wednesday" y='43' CASE dayvar = "Thursday" y='34' CASE dayvar = "Friday" y='25' CASE dayvar = "Saturday" y='16' ENDCASE

********************* End of code *******************

Additional query words: kbvfp600

Keywords: kbhowto kbcode KB190265

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.