# How is DateTime Data Stored?

In Salesforce all Date/Time data is stored in UTC — [Coordinated Universal Time](http://www.timeanddate.com/time/aboututc.html). UTC is not a time zone but rather a time standard used commonly around the world.

For practical purposes, we can assume that UTC is the same as the older GMT (Greenwich Mean Time) standard and is the current time in London, UK.

CopyStorm also stores all Date/Time values in UTC and it is up to an application to convert UTC values to the timezone of each application using the data. This makes a lot of sense for systems with users accessing the same data from wildly different timezones. Each user expects to see Date/Time values displayed in their local time zone!

## How Do I Convert From UTC to My Local Time Zone?

This section lists a few techniques for converting from UTC to the local timezone of the computer hosting the CopyStorm database.

### Microsoft SQL/Server

Example query:

`SELECT systemmodstamp ,DATEADD(hh,((DATEDIFF(ss,systemmodstamp,GETDATE())-DATEDIFF(ss,systemmodstamp,GETUTCDATE()))/3600), systemmodstamp) AS LocalTimestamp FROM Account`

There are two things to note with this solution:

* SQL/Server 2016 has a direct solution to this problem ([see this article](https://docs.microsoft.com/en-us/sql/t-sql/queries/at-time-zone-transact-sql)).
* This example does not take daylight savings time into consideration.
  * See [this script](http://download.capstorm.com/support/SQLServer/FindLocalDateWithDaylightSavingsTime.sql) for a solution that takes daylight savings time into consideration.

### Oracle

Example query:

`SELECT systemmodstamp, systemmodstamp + (systimestamp – SYS_EXTRACT_UTC(systimestamp)) LocalTime FROM Account`

### MySQL

Example query:

`SELECT systemmodstamp, systemmodstamp + INTERVAL (TIMESTAMPDIFF(SECOND, UTC_TIMESTAMP() , NOW())) SECOND FROM Account`

### PostgreSQL

Example query:

`SELECT systemmodstamp, systemmodstamp AT TIME ZONE ‘UTC’ FROM Account`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.capstorm.com/frequently-asked-questions/how-does-copystorm-work/how-is-datetime-data-stored.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
