---
title: "SQL-004: Retrieve current server date/time"
summary: Retrieves the database server's current date/time, with an engine-selected statement chosen at ISessionHelper construction time.
status: draft
owner: Framework
last_reviewed: 2026-09-15
library: SAIF.Framework.Data.NHibernate
reference_type: package
---

# SQL-004: Retrieve current server date/time

This statement backs `SessionHelperBase.SystemDate`, an infrastructure utility consumed by `RepositoryBase<TEntity>.SystemDate`. The exact text executed is engine-dependent: it is selected at `ISessionHelper` construction time by which subclass (`OracleSessionHelper` vs. `SqlServerSessionHelper`) was built for the active unit of work (`Factories/UnitOfWorkFactoryBase.cs::BuildSessionHelper`). The getter falls back to local `DateTime.Now` if the query result is null, `DateTime.MinValue`, or `DateTime.MaxValue` — see [BR-004](../business-rules.md#br-004-systemdate-falls-back-to-local-clock).

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-004 |
| **Operation type** | Read |
| **Execution method** | Inline SQL (`ISessionStrategy.CreateSqlQuery`), engine-selected text |
| **Database** | Oracle / SQL Server (engine-dependent) |
| **Schema** | `[unqualified]**` |
| **Command type** | Text |
| **Business object** | N/A — infrastructure utility, not tied to a mapped entity |
| **Criteria property** | N/A — no `IBusinessCriteria` exists in this library |
| **Lifecycle method** | `SessionHelperBase.SystemDate` (get accessor); engine text set in `OracleSessionHelper`/`SqlServerSessionHelper` constructors |

## Parameters

No parameters — both variants are literal, parameterless server-time queries with no bind variables.

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| — | SELECT (scalar value; Oracle reads the `DUAL` pseudo-table, SQL Server reads no table) | — |

## Sample SQL

Oracle variant (`SessionHelper/OracleSessionHelper.cs`):
```sql
select sysdate
from dual
```

SQL Server variant (`SessionHelper/SqlServerSessionHelper.cs`):
```sql
Select GetDate()
```

## Operations and processes
- [Repository CRUD and query operations (stateful vs stateless divergence)](../operations-processes.md#repository-crud-and-query-operations-stateful-vs-stateless-divergence)

## Business rules
- [BR-004](../business-rules.md#br-004-systemdate-falls-back-to-local-clock) — this statement is the query [BR-004](../business-rules.md#br-004-systemdate-falls-back-to-local-clock) describes; the local-clock fallback behavior in `SessionHelperBase.SystemDate`'s getter is the enforcement point, and this statement is the query it depends on for its primary (non-fallback) result.

## Sources
- `SessionHelper/SessionHelperBase.cs`
- `SessionHelper/OracleSessionHelper.cs`
- `SessionHelper/SqlServerSessionHelper.cs`
