xsharp.eu • Best Practices: Date conversion
Page 1 of 1

Best Practices: Date conversion

Posted: Fri Sep 10, 2021 12:40 pm
by OhioJoe
Moving from DBF to SQL. When I did this before (to SQLite) I converted the DBF dates to strings:
09/10/2021 becomes "20210910"
The table column was an 8-space Char type. Easy to convert and fairly easy to adjust the programming logic throughout the app.
My question is:
Is this the way to do it going forward, or should I use another approach?
Trying to use a common date format that works across all SQL database types.
Thanks everyone.

Best Practices: Date conversion

Posted: Fri Sep 10, 2021 7:31 pm
by Jamal
Joe,

I think it is better to use the ISO Date type for the SQL column. The syntax is: YYYY-MM-DD
VO 2.8 Sql Class Library has DToCSQL(dDate) to convert VO date to a SQL Date. You may also create your own functions to handle date and time values.
for example:

Code: Select all

 ? DToCSQL(Today())    // returns: 2021-09-10
Using SQL date columns will make it to sort and query the data using SQL statements.

Jamal

Best Practices: Date conversion

Posted: Sat Sep 11, 2021 7:48 pm
by OhioJoe
Thank you, Jamal