1 min read

Fetching Date Values into DataFlex Date Field Using Embedded SQL

SQL Server databases have a unique date format. This is a clean way to receive date columns from a statement (stmt) directly to a DataFlex (DF) Table.Field or a Date Variable.


Get_Attribute DF_DATE_FORMAT to iDateFormat_Stmt


If (sDriver_Stmt = "MDSMYSQL") Begin
    If (iDateFormat_Stmt = DF_DATE_USA      ) Move "select code, name, date_format(date1, '%m/%d/%Y') from vi_5778 order by code" to sStmt
    If (iDateFormat_Stmt = DF_DATE_EUROPEAN) Move"select code, name, date_format(date1,'%d/%m,%Y') from vi_5778 order by code" to sStmt
    If (iDateFormat_Stmt = DF_DATE_MILITARY) Move "select code, name, date_format(date1,'%Y/%m/%d') from vi_5778 order by code" to sStmt
End

If sDriver_Stmt = "MDSPGSQL") Begin
    If (iDateFormat_Stmt = DF_DATE_USA      ) Move "select code, name,RTrim(substring(date1 from 6 for 2) || '/' || substring(date1 from 9 for 2) || '/' || substring(date1 from 1 for 4)) as date1 from vi_5778 order by code" to sStmt
    If (iDateFormat_Stmt = DF_DATE_EUROPEAN) Move "select code, name, RTrim(substring(date1 from 9 for 2) || '/' || substring(date1 from 6 for 2) || '/' || substring(date1 from1 for 4)) as date1 from vi_5778 order by code" to sStmt
    If (iDateFormat_Stmt = DF_DATE_MILITARY) Move "select code, name, RTrim(substring(date1 from 1 for 4) || '/' || substring(date1 from 6 for 2) || '/' || substring(date1 from 9 for 2)) as date1 from vi_5778 order by code" to sStmt
End

Tip:

For Flex2SQL we introduced a special command which set it automatically.
It is a Procedure Set named 'SqlUseDataflexDateFormat'


Usage:

Set SqlUseDataflexDateFormat to DFTrue/DFFalse

 

Why Migrate from Btrieve to PostgreSQL and other Relational Databases?

Why Migrate from Btrieve to PostgreSQL and other Relational Databases?

Introduction Many independent software vendors (ISV) and corporate users still rely on applications that use a category of database collective called...

Read More
Four Challenges in Converting COBOL Applications from ISAM Databases to Relational Databases

Four Challenges in Converting COBOL Applications from ISAM Databases to Relational Databases

COBOL applications are the foundation of numerous essential business functions, especially within the banking, insurance, and government sectors....

Read More
Application Modernization 101: Ultimate Guide to Digital Transformation

Application Modernization 101: Ultimate Guide to Digital Transformation

Imagine breaking free from the constraints of old, monolithic systems and embracing the agility and innovation of cloud-based solutions.

Read More