1. Yasir Masood
  2. PowerBuilder
  3. Sunday, 28 May 2023 19:54 PM UTC

Hello,

We are using PB 2017 R3 Build 1858 with SQL Server 2018. I am not sure if this is a bug or a settings issue.

In the PB application when I access a SQL Server datetime field using a datetime variable, milliseconds are missing.

I used both datetime and datetime2 datatype in the SQL Server. But it doesn't work in PB.

The result from SQL Server is          2023-05-28 14:40:48.957    2023-05-28 14:40:48.9566667

And the result from PB is                  2023-05-28 14:40:48           2023-05-28 14:40:48

 

I would appreciate your help.

Thanks

 

Yasir Masood Accepted Answer Pending Moderation
  1. Wednesday, 31 May 2023 02:40 AM UTC
  2. PowerBuilder
  3. # 1

Thank you

Comment
There are no comments made yet.
Peter Pang @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 31 May 2023 02:19 AM UTC
  2. PowerBuilder
  3. # 2

Hi Yasir,

 

It seems to be a precision issue. If you Insert the datetime variable into the table again using the insert statement, you will see that the milliseconds are not missing.

This is a legacy problem, which also exists in PB 12.6.

 

Please open a support ticket in the support portal and please provide a simple PB case & the detailed steps to reproduce the issue, Many thanks in advance.
https://www.appeon.com/standardsupport/

 

Best Regards,

Peter

Comment
There are no comments made yet.
Yasir Masood Accepted Answer Pending Moderation
  1. Wednesday, 31 May 2023 01:03 AM UTC
  2. PowerBuilder
  3. # 3

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 31 May 2023 00:39 AM UTC
  2. PowerBuilder
  3. # 4

Yasir -

Since you have not gone into any details how you are querying the date/time value from SQL Server 2019 and retrieving the value into PB, I have performed some experiments using PB 2017 R3 Build 1915 and SQL Server 2019 via the SNC (OLE DB) native interface.

Below is the SQL SELECT for a test DataWindow that returns a datetime2 value:

If the SELECT statement uses GETDATE() instead of SYSDATETIME(), a datetime value is returned. The time portion of a SQL Server datetime has a resolution of milliseconds (hh:mm:ss.fff) and a datetime2 value provides seven decimal places.

Below is the preview of this DataWindow in the DW Painter:

A time value in PB contains at most six decimal places, so PB drops the seventh decimal place from the datetime2 value supplied by SQL Server.

*** Note ***

I had to alter the default display format for this column object in the DW Painter in order to see the fractional seconds. Normally, the default display format supplied by PB does not include fractional seconds:

If a datetime value is returned in the SELECT statement, only three decimal places are returned:

You can also put a datetime or datetime2 value into a PB datetime variable via inline SQL:

Datetime ldt_now

SELECT GETDATE() 
  INTO :ldt_now 
  FROM (SELECT 1 AS [a_column] AS [dummy_table])
USING SQLCA;

I'm not sure why you think PB is not able to obtain the fractional seconds from SQL Server, but I'm guessing it's because you do not see the fractional seconds displayed in the PB debugger or in a DW column because of the display format:

Remember I stated earlier that PB uses a default display format that omits the fractional seconds... The fractional seconds ARE there:

I hope this helps to resolve your question.

Best regards, John

Comment
  1. Yasir Masood
  2. Wednesday, 31 May 2023 00:58 AM UTC
datetime ldt_arrv_datetime



I am getting the datetime variable in the an event of the datawindow control. I have tried both dot notation and the GetItem function as shown below



ldt_arrv_datetime = dw_list.Object.arrv_date_time[row]

ldt_arrv_datetime = dw_list.GetItemDateTime(row,"arrv_date_time")



Then I am using this variable in embedded SQL as follows



SELECT count(1)

INTO :li_count

FROM table_name

WHERE order_no = :ls_order_no

AND plant_id = :is_plant_id

AND arrv_date_time <> :ldt_arrv_datetime ;



The value for li_count is always 0 even if there are records in the table.



Thanks

  1. Helpful
There are no comments made yet.
Yasir Masood Accepted Answer Pending Moderation
  1. Monday, 29 May 2023 03:29 AM UTC
  2. PowerBuilder
  3. # 5

I don't want to convert the value to a string.

I am using the datetime value in an Embedded SQL

Comment
  1. Roland Smith
  2. Tuesday, 30 May 2023 13:25 PM UTC
My point was that perhaps the milliseconds are in the variable. The debugger doesn't show milliseconds so the only way to see them is to convert to a string.
  1. Helpful 2
  1. Miguel Leeuwe
  2. Tuesday, 30 May 2023 13:32 PM UTC
Correct! I've asked for an enhancement to show the milliseconds in debug quite some time ago. Right now the only way to see them is to convert them to a string (using a "watch" for example) with the appropriate format for the string).
  1. Helpful 2
  1. Yasir Masood
  2. Tuesday, 30 May 2023 15:17 PM UTC
If I convert the date to a string, I can see the milliseconds. I don't understand why the datetime variable is not working in embedded SQL.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 29 May 2023 03:21 AM UTC
  2. PowerBuilder
  3. # 6

When converting a DateTime to String or when displaying in a DataWindow, you need to format it with .fff on the end like so:

ls_date = String(ldt_thedate, "mm/dd/yyyy hh:mm:ss.fff")

 

Comment
  1. Roland Smith
  2. Monday, 29 May 2023 03:23 AM UTC
A while back I put in an enhancement request to support 6 digits of milliseconds.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Monday, 29 May 2023 12:17 PM UTC
I remember that one Roland!
  1. Helpful
There are no comments made yet.
Yasir Masood Accepted Answer Pending Moderation
  1. Sunday, 28 May 2023 21:23 PM UTC
  2. PowerBuilder
  3. # 7

Here is the connection string from my INI file

 

DBParm="PROVIDER='SQLOLEDB',DATASOURCE='YASIRMLPTP1',PROVIDERSTRING='database=DB_NAME',PBTrimCharColumns='YES',INTEGRATEDSECURITY='SSPI',OJSyntax='PB',appname='YM',StaticBind=0"

Comment
  1. John Fauss
  2. Monday, 29 May 2023 02:16 AM UTC
Thank you, Yasir. If I may ask another question: There is no SQL Server database version 2018, but there are 2017 and 2019 versions. Are you referring to the version of SQL Server Management Studio? If so, what version of the SQL Server database are you using?
  1. Helpful
  1. Yasir Masood
  2. Monday, 29 May 2023 02:20 AM UTC
My mistake, we are using SQL Server 2019
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Sunday, 28 May 2023 20:03 PM UTC
  2. PowerBuilder
  3. # 8

Hi Yasir;

  What DB client are you using to connect to SS!

Ie: SQLCA = "???"

Regards ... Chris 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.