Data Access Worldwide Knowledge Base

Article ID 2311
Article Title INFO: Return Value from DateSetxxx Functions
Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2311
KBase Category VDF12
Date Created 05/09/2007
Last Edit Date 05/11/2007


Article Text
An important change was made in Visual DataFlex regarding DateSetxxx functions and their return values. Prior to 12.1 invalid DateTime values would be automatically adjusted to a valid value. In 12.1 invalid DateTime values are instead preserved as is, and no longer automatically adjusted.

Details
-------
The runtime and the debugger have changed and the behavior of the DateSetxxx functions (DateSetDay, DateSetMonth, DateSetYear) in Visual DataFlex Studio has progressed as follows:

In Visual DataFlex 11.1:
- Showln
For invalid dates, showln would show the DateTime variable adjusted forward (e.g. setting a DateTime variable to 4/31/2007 2:57:39 PM, would result in a DateTime of 5/1/2007 2:57:39 PM being displayed)

For wrong dates, like 5/32/2007 2:57:39 PM, showln would show blank for the DateTime variable

- Debugger
For invalid and wrong dates, the debugger would show the date in the list of variables using the values passed to the function (e.g. setting a DateTime variable to 4/31/2007 2:57:39 PM, the debugger would display 4/31/2007 2:57:39 PM; setting a DateTime variable to 5/32/2007 2:57:39 PM, the debugger would display 5/32/2007 2:57:39 PM)

- DateGetxxx would always display the value passed to the function, correct/valid or not

- IsDateValid would be True when the value passed to the function was invalid (like 4/31/2007 2:57:39 PM -- in this case the resulting value of the DateTime variable would be adjusted to a valid date of 5/1/2007 2:57:39 PM) and False when the value passed to the function was wrong (like 5/32/2007 2:57:39 PM)



In Visual DataFlex 12.0:
- Showln
For invalid dates, showln would show the DateTime variable adjusted forward (e.g. setting a DateTime variable to 4/31/2007 2:57:39 PM, would result in a DateTime of 5/1/2007 2:57:39 PM being displayed)

For wrong dates, like 5/32/2007 2:57:39 PM, showln would show blank for the DateTime variable

- Debugger
For invalid dates, the debugger would display the DateTime variable adjusted forward (e.g. setting a DateTime variable to 4/31/2007 2:57:39 PM, would result in a DateTime of 5/1/2007 2:57:39 PM being displayed)

For wrong dates, the debugger would display "Invalid DateTime" (e.g. setting a DateTime variable to day 32, like 5/32/2007 2:57:39 PM, would result in "Ivalid DateTime" being displayed)

- DateGetxxx would always display the value passed to the function, correct/valid or not

- IsDateValid would be True when the value passed to the function was invalid (like 4/31/2007 2:57:39 PM -- in this case the resulting value of the DateTime variable would be adjusted to a valid date of 5/1/2007 2:57:39 PM) and False when the value passed to the function was wrong (like 5/32/2007 2:57:39 PM)



In Visual DataFlex 12.1:
- Showln
Showln shows the return DateTime value in the list of variables (e.g. showln displays 4/31/2007 2:57:39 PM when setting a DateTime variable to 4/31/2007 2:57:39 PM; showln displays 5/32/2007 2:57:39 PM when setting a DateTime variable to 5/32/2007 2:57:39 PM)

- Debugger
The debugger shows the DateTime value in the list of variables (e.g. the debugger displays 4/31/2007 2:57:39 PM when setting a DateTime variable to 4/31/2007 2:57:39 PM; the debugger displays 5/32/2007 2:57:39 PM when setting a DateTime variable to 5/32/2007 2:57:39 PM)

- DateGetxxx always displays the value passed to the function, correct/valid or not

- IsDateValid will be False when the value passed to the function is invalid (like 4/31/2007 2:57:39 PM) and when the value passed to the function is wrong (like 5/32/2007 2:57:39 PM)



Example:

        Procedure OnClick
            DateTime dtVar
            Integer Year Month Day
            Boolean bOK
            
            Move (CurrentDateTime())  to dtVar //(CurrentDateTime())
            Showln "Current DateTime: " dtVar
            Showln

            Move (DateSetDay(dtVar, 31)) to dtVar
            Showln "After DateSetDay(dtVar, 31): " dtVar            
            Move (DateSetMonth(dtVar, 04)) to dtVar
            Showln "After DateSetMonth(dtVar, 04): " dtVar
            Move (DateSetMonth(dtVar, 02)) to dtVar
            Showln "After DateSetMonth(dtVar, 02): " dtVar
            Move (DateSetDay(dtVar, 30)) to dtVar
            Showln "After DateSetDay(dtVar, 30):      " dtVar
            Move (DateSetDay(dtVar, 29)) to dtVar
            Showln "aAfter DateSetDay(dtVar, 29): " dtVar  
            Move (IsDateValid(dtVar)) to bOK
            Showln bOK
            Move (DateSetDay(dtVar, 32)) to dtVar
            Showln "After DateSetDay(dtVar, 31): " dtVar
            Move (DateSetYear(dtVar, 2006)) to dtVar
            Showln "After DateSetYear(dtVar, 2006): " dtVar
            Showln

            Move (DateGetDay(dtVar)) to Day
            Showln "DateGetDay: " Day
            Move (DateGetMonth(dtVar)) to Month
            Showln "DateGetMonth: " Month
            Move (DateGetYear(dtVar)) to Year
            Showln "DateGetYear: " Year
            Showln
            
            Move (IsDateValid(dtVar)) to bOK
            Showln "IsDateValid: " bOK
            
            Showln "dtVar: " dtVar
                      
        End_Procedure

Using the above code and assuming the routine was run on 5/9/2007 at 4:19:43.455 PM, the results in 12.1 (in the debugger and showln) will be:

Current DateTime: 5/9/2007 4:19:43.455 PM

After DateSetDay(dtVar, 31): 5/31/2007 4:19:43.455 PM
After DateSetMonth(dtVar, 04): 4/31/2007 4:19:43.455 PM
After DateSetMonth(dtVar, 02): 2/31/2007 4:19:43.455 PM
After DateSetDay(dtVar, 30):      2/30/2007 4:19:43.455 PM
aAfter DateSetDay(dtVar, 29): 2/29/2007 4:19:43.455 PM
0
After DateSetDay(dtVar, 31): 2/32/2007 4:19:43.455 PM
After DateSetYear(dtVar, 2006): 2/32/2006 4:19:43.455 PM

DateGetDay: 32
DateGetMonth: 2
DateGetYear: 2006

IsDateValid: 0
dtVar: 2/32/2006 4:19:43.455 PM


Contributed By:
Marcia Booth
Company: Data Access Worldwide
Web Site: http://www.dataaccess.com


Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2010 Data Access Corporation. All rights reserved.

The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.