Android Question How do I indicate a date = "0000-00-00" in jRDC2, in the Config.Properties file?

Sergio Castellari

Active Member
Licensed User
Hello there,
I need to create a SQL command that validates a DATE field with value 0000-00-00 in the file "config.properties" of the jRDC2 server
I have already tried in different ways:
a) sql.select_ctacte_saldo_clie=Select Sum(SALDO) as SALDO From CLIENTE Where FECHAEGRE='0000-00-00'
b) sql.select_ctacte_saldo_clie=Select Sum(SALDO) as SALDO From CLIENTE Where FECHAEGRE=”0000-00-00”
c) sql.select_ctacte_saldo_clie=Select Sum(SALDO) as SALDO From CLIENTE Where FECHAEGRE=0
They all return the following error:
<title>Error 500 java.sql.SQLException: Value &apos;0000-00-00&apos; can not be represented as java.sql.Date</title>

I have also tried with:
a) sql.select_ctacte_saldo_clie=Select Sum(SALDO) as SALDO From CLIENTE Where FECHAEGRE=null
In this case no error, but it does not bring any record

The FECHAEGRE field in the database can have the value 0000-00-00 or a date in YYYY-MM-DD format, for example: 2021-09-05
How should I create the SQL command so that it filters all the fields with FECHAEGRE = 0000-00-00?
Greetings and thanks!
 

OliverA

Expert
Licensed User
Try this: https://stackoverflow.com/a/24093796

1) Add zeroDateTimeBehavior=convertToNull to the database URL
2) Use FECHAEGRE=null in the SQL statement

Note: The assumption here is that you are using MySQL, otherwise, another solution needs to be found
 
Upvote 2

Sergio Castellari

Active Member
Licensed User
@OliverA
BRILLIANT!!!
I work with your recommendations!
I only had to change point 2) to "DATEE" = "0000-00-00" because in the database I do not use "null" but "0000-00-00"
Your assumption is correct, I use MySQL (sorry I forgot to clarify it)

Thanks again a million!
Greetings

NOTE: I have learned very interesting new things thanks to you!
 
Upvote 0
Top