PDA

View Full Version : DF Dates & MSSQL DateTime: Error on European Dates > 12th of the month



Mike Peat
11-May-2017, 01:10 PM
I don't know if this is a new error in 19.0 (I suspect not, but beta 3 of that is what I am working with), but if the date format is set to DF_DATE_EUROPEAN a DataFlex Date (or DateTime) with a "day" value > 12 causes an error if moved to an MSSQL DateTime type column.

The following code errors (written on the May 11th, so the error happens on the third time through the loop and thereafter):



Use Windows.pkg

Set_Attribute DF_DATE_FORMAT to DF_DATE_EUROPEAN

Open "GSjobdet.int" as Gsjobdet

Procedure DateTest
DateTime dtTest
Date dTest
Integer i

Sysdate dTest

For i from 0 to 9
Move dTest to dtTest
Move dtTest to GSJOBDET.ASSIGNEDDATE
Move (DateAddDay(dTest, 1)) to dTest // Could use "Increment dTest" here, but I'm being good! <g>
Loop

End_Procedure

Send DateTest


(Note: I am using the Open AS approach to keep the code simple.)

GSJOBDET.ASSIGNEDDATE is MSSQL type "datetime".

Moving either dTest or dtTest to it causes an error: "Please enter a valid date" when the Watches window shows dTest as 13/05/2017 and dtTest as 5/13/2017 12:00:00 AM.

Any thoughts on how to fix/avoid the problem? I'm sure this must have come up before, but I can't find any mention of it.

Mike

Mike Peat
12-May-2017, 10:52 AM
It was regional settings - Windows was using US dates.

Case closed.

Mike

Dennis Piccioni
12-May-2017, 11:04 AM
Hi Mike,

thanks for the update! :)

wila
12-May-2017, 11:54 AM
It was regional settings - Windows was using US dates.

Case closed.

Mike

Not sure I would call that "case closed", sounds more like a bug report to me.



Set_Attribute DF_DATE_FORMAT to DF_DATE_EUROPEAN


overrides the date settings for all other date handling.
If it doesn't do that here when using datetime functions then that smells like a bug or at least documentation issue.

From the help:

By default, the DF_DATE_FORMAT will conform to the regional settings on the machine. Windows visual controls also use the regional settings. If the DF_DATE_FORMAT does not conform to the regional settings, errors will occur when using certain Windows controls. For this reason you should only set this attribute on a temporary basis or in programs that have no user interface.

So perhaps add there that it also doesn't work for datetime functions? As it certainly is not a windows visual control..

--
Wil

Samuel Pizarro
12-May-2017, 04:13 PM
I agree with you!

we need some consistency here.

Mike Peat
17-May-2017, 05:03 AM
Wil

In fact this was in a (RESTful! :)) web service - no UI, no Windows stuff, nuthin' but plain old DataFlex. It sure felt like a bug when I was looking at it. It happened all of a sudden that day - worked in the morning; borken in the afternoon. Some configuration work was being done on the server in that timeframe, so I guess the Windows regional settings got changed somehow.

Mike