Welcome! Log In Create A New Profile

Advanced

WD23 - native SQL DateTime2 datatype error

Posted by ArieM 
WD23 - native SQL DateTime2 datatype error
February 22, 2020 03:27PM
Hi all,

I'm in the middle of converting a large application from HFSQL to MSSQL. Works fine on most parts and the overall performance is at least 25% faster now. I'm using the native driver.

But datetime fields can be a pain in the…

From the analysis pane, Windev creates sql scripts to create tables and alle datetime fields are defined as DateTime2(3), which seems to be correct for MSSQL 2012 and above. Windev help also recommends this fieldtype.

At most places in the application this works fine. But somehow on a few places an exception is thrown.
"Conversion failed when converting date and/or time from character string."

No difference in code as far as I can tell, just basic lines like
Tbl_Users.ModifiedDateTime = DateSys() - TimeSys()

What am I missing here? Do I need some special considerations using datetime fields?

Arie
pao
Re: WD23 - native SQL DateTime2 datatype error
February 24, 2020 03:05PM
Arie,
Is the code you paste here the same used in the your app? Tbl_Users.ModifiedDateTime = DateSys() - TimeSys()

If it's the code used in your app is wrong it should be Tbl_Users.ModifiedDateTime = DateSys() + TimeSys()

Regards

Paulo Oliveira



Edited 1 time(s). Last edit at 02/24/2020 04:09PM by pao.
Re: WD23 - native SQL DateTime2 datatype error
February 24, 2020 07:40PM
Uh by bad. Llittle typo in the post, should be a +sign indeed.

Arie
Re: WD23 - native SQL DateTime2 datatype error
February 24, 2020 07:44PM
I did some more testing and when I use Datetime instead of Datetime2 the errors are gone.

So maybe I should rephrase my question:
Fr those who are using the native MSSQL drive, of which type are your fields in MSSQL for the following Windev types,
Date
Time
Datetime

Arie
pao
Re: WD23 - native SQL DateTime2 datatype error
February 26, 2020 10:21AM
I'm using datetime for all this type of columns because some of my clients still have mssql 2005.

Regards

Paulo Oliveira



Edited 1 time(s). Last edit at 02/26/2020 01:13PM by pao.
Re: WD23 - native SQL DateTime2 datatype error
February 28, 2020 05:12PM
It turns out that it only effects some very old tables in my analysis. These are from the days back in WD9. I removed them from the analysis and created them from scratch. Problem gone.

Arie
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: