API/CodeSamples/How-can-I-add-the-system-date-and-time-into-my-report.md
... ...
@@ -0,0 +1,40 @@
1
+#Adding system date and time to a report
2
+
3
+[[_TOC_]]
4
+
5
+##Question
6
+
7
+I have an older version of Izenda. How do I add the system date and time into my report if there is no checkbox on the Style tab?
8
+
9
+##Answer
10
+
11
+Place this custom code into your global.asax:
12
+
13
+```csharp
14
+
15
+public class CustomAdHocConfig : DatabaseAdHocConfig
16
+{
17
+ // Key-value collection of reports identifiers
18
+ // and dates to remove from title
19
+ private Hashtable _datesToRemove = new Hashtable();
20
+
21
+ public override void PreExecuteReportSet(Izenda.AdHoc.ReportSet reportSet)
22
+ {
23
+ string date = System.DateTime.Now.ToString("dd/MM/yyyy", new System.Globalization.CultureInfo("en-US"));
24
+ // Alter the report title by adding a new line and the date and time
25
+ reportSet.Title = reportSet.Title + Environment.NewLine + date;
26
+ // Save just added value, so we will be able to remove it after
27
+ if (!_datesToRemove.Contains(reportSet.ReportID))
28
+ _datesToRemove.Add(reportSet.ReportID, date);
29
+ else
30
+ _datesToRemove[reportSet.ReportID] = date;
31
+ }
32
+
33
+ public override void PostExecuteReportSet(ReportSet reportSet)
34
+ {
35
+ // Remove data from the report title
36
+ if (_datesToRemove.Contains(reportSet.ReportID))
37
+ reportSet.Title = reportSet.Title.Replace(_datesToRemove[reportSet.ReportID].ToString(), String.Empty);
38
+ }
39
+}
40
+```
... ...
\ No newline at end of file