diff --git a/src/sbbs3/getstats.c b/src/sbbs3/getstats.c
index 21bce3932a47b9f2a4c3d1b2f3d20175f640f71f..f4db8a751cd97cec5a78a999ac963c2f34afe324 100644
--- a/src/sbbs3/getstats.c
+++ b/src/sbbs3/getstats.c
@@ -23,6 +23,7 @@
 #include "nopen.h"
 #include "smblib.h"
 #include "ini_file.h"
+#include "datewrap.h"
 #include "xpendian.h"
 #include "xpdatetime.h"
 #include "scfglib.h"
@@ -210,7 +211,23 @@ static void settotals(str_list_t* ini, const char* section, const totals_t* stat
 
 /****************************************************************************/
 /****************************************************************************/
-bool fwrite_dstats(FILE* fp, const stats_t* stats)
+static bool write_dstats(FILE* fp, str_list_t* ini, const char* function)
+{
+	time_t now = time(NULL);
+	char tstr[32];
+	char value[INI_MAX_VALUE_LEN + 1];
+	const char* key = "LastWrite";
+	char* last = iniGetString(*ini, ROOT_SECTION, key, NULL, value);
+	if(last != NULL)
+		iniSetString(ini, ROOT_SECTION, "PrevLastWrite", last, NULL);
+	safe_snprintf(value, sizeof value, "%.24s by %s", ctime_r(&now, tstr), function);
+	iniSetString(ini, ROOT_SECTION, key, value, NULL);
+	return iniWriteFile(fp, *ini);
+}
+
+/****************************************************************************/
+/****************************************************************************/
+bool fwrite_dstats(FILE* fp, const stats_t* stats, const char* function)
 {
 	bool result;
 	str_list_t ini;
@@ -222,7 +239,7 @@ bool fwrite_dstats(FILE* fp, const stats_t* stats)
 	iniSetDateTime(&ini, NULL, strStatsDate, /* include_time: */false, stats->date, /* style: */NULL);
 	settotals(&ini, strStatsToday, &stats->today);
 	settotals(&ini, strStatsTotal, &stats->total);
-	result = iniWriteFile(fp, ini);
+	result = write_dstats(fp, &ini, function);
 	iniFreeStringList(ini);
 
 	return result;
@@ -238,7 +255,7 @@ bool putstats(scfg_t* cfg, uint node, const stats_t* stats)
 	FILE* fp = fopen_dstats(cfg, node, /* for_write: */true);
 	if(fp == NULL)
 		return false;
-	result = fwrite_dstats(fp, stats);
+	result = fwrite_dstats(fp, stats, __FUNCTION__);
 	iniCloseFile(fp);
 	return result;
 }
@@ -376,7 +393,7 @@ static bool inc_xfer_stats(scfg_t* cfg, uint node, uint files, uint64_t bytes, c
 	ini = iniReadFile(fp);
 	inc_xfer_stat_keys(&ini, strStatsTotal, files, bytes, files_key, bytes_key);
 	inc_xfer_stat_keys(&ini, strStatsToday, files, bytes, files_key, bytes_key);
-	result = iniWriteFile(fp, ini);
+	result = write_dstats(fp, &ini, __FUNCTION__);
 	fclose_dstats(fp);
 	iniFreeStringList(ini);
 
@@ -413,7 +430,7 @@ static bool inc_post_stat(scfg_t* cfg, uint node, uint count)
 	ini = iniReadFile(fp);
 	iniSetUInteger(&ini, strStatsToday, strStatsPosts, iniGetUInteger(ini, strStatsToday, strStatsPosts, 0) + count, /* style: */NULL);
 	iniSetUInteger(&ini, strStatsTotal, strStatsPosts, iniGetUInteger(ini, strStatsTotal, strStatsPosts, 0) + count, /* style: */NULL);
-	result = iniWriteFile(fp, ini);
+	result = write_dstats(fp, &ini, __FUNCTION__);
 	fclose_dstats(fp);
 	iniFreeStringList(ini);
 
@@ -441,7 +458,7 @@ static bool inc_email_stat(scfg_t* cfg, uint node, uint count, bool feedback)
 	ini = iniReadFile(fp);
 	iniSetUInteger(&ini, strStatsToday, key, iniGetUInteger(ini, strStatsToday, key, 0) + count, /* style: */NULL);
 	iniSetUInteger(&ini, strStatsTotal, key, iniGetUInteger(ini, strStatsTotal, key, 0) + count, /* style: */NULL);
-	result = iniWriteFile(fp, ini);
+	result = write_dstats(fp, &ini, __FUNCTION__);
 	fclose_dstats(fp);
 	iniFreeStringList(ini);
 
diff --git a/src/sbbs3/getstats.h b/src/sbbs3/getstats.h
index 79a0a4ab50a40c0d154644eaca29ed05da4858c9..8390caeca6db0e2d5d0cf5a91afedd315aefb68a 100644
--- a/src/sbbs3/getstats.h
+++ b/src/sbbs3/getstats.h
@@ -35,7 +35,7 @@ DLLEXPORT FILE*		fopen_cstats(scfg_t*, uint node, bool for_write);
 DLLEXPORT bool		fclose_cstats(FILE*);
 DLLEXPORT bool		fclose_dstats(FILE*);
 DLLEXPORT bool		fread_dstats(FILE*, stats_t*);
-DLLEXPORT bool		fwrite_dstats(FILE*, const stats_t*);
+DLLEXPORT bool		fwrite_dstats(FILE*, const stats_t*, const char* function);
 DLLEXPORT bool		fwrite_cstats(FILE*, const stats_t*);
 DLLEXPORT void		parse_cstats(str_list_t, stats_t*);
 DLLEXPORT bool		getstats(scfg_t*, uint node, stats_t*);
diff --git a/src/sbbs3/logon.cpp b/src/sbbs3/logon.cpp
index e6a8f09e430cc791963aab362c5ca253ba4c92d7..78358189f0f2c4a40e5b65b9fad1c449f70e5402 100644
--- a/src/sbbs3/logon.cpp
+++ b/src/sbbs3/logon.cpp
@@ -657,7 +657,7 @@ uint sbbs_t::logonstats()
 			fwrite_cstats(csts, &stats);
 			fclose_cstats(csts);
 			rolloverstats(&stats);
-			fwrite_dstats(dsts, &stats);
+			fwrite_dstats(dsts, &stats, __FUNCTION__);
 			fclose_dstats(dsts);
 		} 
 	}
@@ -680,7 +680,7 @@ uint sbbs_t::logonstats()
 		fread_dstats(fp, &stats);
 		stats.today.logons++;
 		stats.total.logons++;
-		fwrite_dstats(fp, &stats);
+		fwrite_dstats(fp, &stats, __FUNCTION__);
 		fclose_dstats(fp);
 	}
 
diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp
index 6cb7daac4089fb995bbd3406f345845183b8b088..34b3f110e4f80222526fa00d3c907ce71f10c8e4 100644
--- a/src/sbbs3/main.cpp
+++ b/src/sbbs3/main.cpp
@@ -4382,7 +4382,7 @@ void sbbs_t::logoffstats()
 		if(fread_dstats(fp, &stats)) {
 			stats.total.timeon += minutes_used;
 			stats.today.timeon += minutes_used;
-			fwrite_dstats(fp, &stats);
+			fwrite_dstats(fp, &stats, __FUNCTION__);
 		}
 		fclose_dstats(fp);
 	}
diff --git a/src/sbbs3/userdat.c b/src/sbbs3/userdat.c
index 37b126f6cde5fe93ce355af7e63edb0981875b9d..c5a7f2750465c4a2249b06256595decd48486de7 100644
--- a/src/sbbs3/userdat.c
+++ b/src/sbbs3/userdat.c
@@ -3303,7 +3303,7 @@ int newuserdat(scfg_t* cfg, user_t* user)
 		if(fread_dstats(fp, &stats)) {
 			stats.today.nusers++;
 			stats.total.nusers++;
-			fwrite_dstats(fp, &stats);
+			fwrite_dstats(fp, &stats, __FUNCTION__);
 		}
 		fclose_dstats(fp);
 	}