B4J Question jRDC2 : How to get exact date value stored on server?

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

I have a field with date type. The value is 5/25/18 (MM/dd/yy format).

When retrieved with jRDC2, the value could become 5/29/18 because jRDC2 will convert it to current time zone on device.

I want to get the exact date value stored on server without depend on time zone in the device. How to do that ?

Thanks in advance.
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are several mistakes or inaccuracies in your question.

I have a field with date type. The value is 5/25/18 (MM/dd/yy format).
As this is not a string the value you wrote is more or less meaningless. What does this value represent? In which time zone?

When retrieved with jRDC2, the value could become 5/29/18 because jRDC2 will convert it to current time zone on device.
jRDC2 doesn't convert anything.
 
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
The value is in string format using this codes
B4X:
Sub RptDtlStck(result As DBResult)
    Main.SQLMem.ExecNonQuery("delete from MEM_SLS_ERR")
    Private Dt,FrmN,Art,Dscp As String
    Private Qty_In,Qty_Ot,Blnc As Int
    
    Art = RptUI.RptParams.Get("Art")
    
    For Each records() As Object In result.Rows
        If records(5) <> Null Then
            Dt        = DateTime.Date(records(0))
            FrmN   = records(1)
            Dscp    = Dt & "-" & FrmN & CRLF & records(2)           
            Qty_In = 0
            Qty_Ot = 0
            Blnc     = 0
            
            If records(3) <> Null Then Qty_In = records(3)
            If records(4) <> Null Then Qty_Ot = records(4)
            If records(5) <> Null Then Blnc = records(5)
            Main.SQLMem.ExecNonQuery2("insert into MEM_SLS_ERR (ART,DSCP,QTY_IN,QTY_OT,BLNC) values(?,?,?,?,?)", Array As Object(Art,Dscp,Qty_In,Qty_Ot,Blnc))
        End If       
    Next
End Sub

In server, value return to records(0) is a date type. On Program, this value converted with DateTime function to string.

The Time zone in device was different with time zone in server, I think it was GMT +4, while on server GMT +7.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can set the app time zone to be the same as the server time zone with DateTime.SetTimeZone. This is usually a mistake but it is possible.

A better solution is to decide what exactly this value represents and store it in a better way. Storing it as a ticks value is a good option. Another option is to store it as a string in a format that includes the time zone.
 
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
Storing date as string in database server is not an option cause this value needed for a date calculation.

I am not sure if firebird support store date as a ticks value, so I guess I will take DateTime.SetTimeZone approach on the device. After all, for now, on the display, date value only used as a display, not calculation needed.

Thanks for your helps.
 
Upvote 0
Top