diff --git a/all.sas b/all.sas
index e8a1427..b02ecc0 100644
--- a/all.sas
+++ b/all.sas
@@ -369,6 +369,48 @@ https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md#functionex
%mend mf_existvarlist;
/** @endcond *//**
+ @file
+ @brief Returns E8601DT26.6 if compatible else DATETIME19.3
+ @details From our experience in [Data Controller for SAS]
+ (https://datacontroller.io) deployments, the E8601DT26.6 datetime format has
+ the widest support when it comes to pass-through SQL queries.
+
+ However, it is not supported in WPS or early versions of SAS 9 (M3 and below)
+ when used as a datetime literal, eg:
+
+ data _null_;
+ demo="%sysfunc(datetime(),E8601DT26.6)"dt;
+ demo=;
+ run;
+
+ This macro will therefore return DATEITME19.3 as an alternative format
+ based on the runtime environment so that it can be used in such cases, eg:
+
+ data _null_;
+ demo="%sysfunc(datetime(),%mf_fmtdttm())"dt;
+ demo=;
+ run;
+
+
Related Macros
+ @li mf_fmtdttm.test.sas
+
+ @author Allan Bowe
+**/
+
+%macro mf_fmtdttm(
+)/*/STORE SOURCE*/;
+
+%if "&sysver"="9.2" or "&sysver"="9.3"
+ or ("&sysver"="9.4" and "%substr(&SYSVLONG,9,1)" le "3")
+ or "%substr(&sysver,1,1)"="4"
+ or "%substr(&sysver,1,1)"="5"
+%then %do;DATETIME19.3%end;
+%else %do;E8601DT26.6%end;
+
+%mend mf_fmtdttm;
+
+
+/**
@file
@brief Returns the appLoc from the _program variable
@details When working with SASjs apps, web services / tests / jobs are always
@@ -9259,6 +9301,7 @@ options ibufsize=&ibufsize;
@param [in] loop_secs= (1) Seconds to wait between each lock attempt
SAS Macros
+ @li mf_fmtdttm.sas
@li mp_abort.sas
@li mp_lockfilecheck.sas
@li mf_getuser.sas
@@ -9348,7 +9391,7 @@ run;
LOCK_LIB ="&lib";
LOCK_DS="&ds";
LOCK_STATUS_CD='LOCKED';
- LOCK_START_DTTM="%sysfunc(datetime(),E8601DT26.6)"dt;
+ LOCK_START_DTTM="%sysfunc(datetime(),%mf_fmtdttm())"dt;
LOCK_USER_NM="&user";
LOCK_PID="&sysjobid";
LOCK_REF="&ref";
@@ -9368,7 +9411,7 @@ run;
proc sql;
update &ctl_ds
set LOCK_STATUS_CD='LOCKED'
- , LOCK_START_DTTM="%sysfunc(datetime(),E8601DT26.6)"dt
+ , LOCK_START_DTTM="%sysfunc(datetime(),%mf_fmtdttm())"dt
, LOCK_USER_NM="&user"
, LOCK_PID="&sysjobid"
, LOCK_REF="&ref"
@@ -9443,7 +9486,7 @@ run;
proc sql;
update &ctl_ds
set LOCK_STATUS_CD='UNLOCKED'
- , LOCK_END_DTTM="%sysfunc(datetime(),E8601DT26.6)"dt
+ , LOCK_END_DTTM="%sysfunc(datetime(),%mf_fmtdttm())"dt
, LOCK_USER_NM="&user"
, LOCK_PID="&sysjobid"
, LOCK_REF="&ref"
@@ -10232,6 +10275,7 @@ run;
SAS Macros
@li mf_existvar.sas
+ @li mf_fmtdttm.sas
@li mf_getquotedstr.sas
@li mf_getuniquename.sas
@li mf_nobs.sas
@@ -10391,12 +10435,12 @@ quit;
set keytable="&base_libds"
,keycolumn="&retained_key"
,max_key=%eval(&maxkey+&newkey_cnt)
- ,processed_dttm="%sysfunc(datetime(),E8601DT26.6)"dt;
+ ,processed_dttm="%sysfunc(datetime(),%mf_fmtdttm())"dt;
%end;
%else %do;
update &maxkeytable
set max_key=%eval(&maxkey+&newkey_cnt)
- ,processed_dttm="%sysfunc(datetime(),E8601DT26.6)"dt
+ ,processed_dttm="%sysfunc(datetime(),%mf_fmtdttm())"dt
where keytable="&base_libds";
%end;
%mp_lockanytable(UNLOCK