Retrieving dates from SQLIte
Posted
#1
(In Topic #450)
Trainee
Here is the actual statement: "Select PDate, VMake, VMiles from Vehicles Where Vreg = " & "'" & sVeh & "'"
The date returned should be 12/04/2019 but what is actually returned is 20/04/1912 00:00:00
Can anyone shed some light on the problem please?
Posted
Expert

I'll make the assumption that you are running the latest Gambas 3 version.
What date 'Mode' do you have set for the control ?
Can you show the code where you are applying the returned value to the control ?
MyDataBox.Value = ?
If you are using a variable for this, how is it declared ?
ie: passing the value back from a subroutine or function.
or
Are you doing this directly after the query ?
MyDateBox.Value = MyResult!PDATE
Minor thing and nothing to do with the issue you are having.
Always put your WHERE clauses in brackets : Where(Vreg = " & "'" & sVeh & "'")
where you have more than one comparison - get into the habit now as with more
complex queries it can lead to some perplexing errors especially when you are doing multiple joins.
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Trainee
1. The mode of the Datebox is set to Dateonly.
2. I am using a variable "dPurchase" which is declared as a Date. (Dim dPurchase As Date)
3. I am applying the returned value directly from the query. (dPurchase = $rData1!PDate)
4. This is the code for applying the value to the control.
sSQL3 = "Select PDate, VMake, VMiles from Vehicles Where Vreg = " & "'" & sVeh & "'"
dtbPurDt.ReadOnly = False
dtbPurDt.Value = dPurchase
It puts a value of 20/04/1912 in the control instead of 12/04/2019.
_______________________________________________________________________________________________________
Interestingly, in another part of the program (different form) I have a similar query and it works just fine.
sSQL = "Select TransDate, Odometer from VehicleData Where VehType =" & "'" & sReg & "'" & "Order by Odometer Desc"
$sRes = MODMain.$Con.Exec(sSQL)
dDate = $sRes!TransDate
dtbTransDate.ReadOnly = False
lblTransDate.text = "Last transaction date"
dtbTransDate.Value = dDate
Posted
Expert

My thinking is around trying to determine if the error is from the underlying data in the SQL database.
Everything else, from what I can see is ok.
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Trainee
Your assistance is greatly appreciated. Now I just want to try and "publish" the program so that I can send it to a friend to use. Let's see if I can do it successfully.
Best regards.
1 guest and 0 members have just viewed this.



