---
title: "How to Extract DATE and TIME from TIMESTAMP: DB2"
description: "The easy ways to extract DATE and TIME in DB2. Use these examples in your project at once. Also, these examples are for you to do DATE and TIME calculations."
url: https://srinimf.com/2023/12/27/how-to-get-date-and-time-from-timestamp-in-db2/
date: 2023-12-27
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2023/12/date-time-calculations.jpg?fit=2240%2C1260&ssl=1
categories: ["DB2"]
tags: ["db2 date and time functions", "DB2 Tips and Solutions"]
type: post
lang: en
---

# How to Extract DATE and TIME from TIMESTAMP: DB2

Extracting the [date and time](https://srinimf.com/2016/03/28/how-to-merge-date-and-time-with-timestamp-from-table-columns/) independently from a timestamp is an easy way. In DB2, you can extract the date and time from a timestamp using SQL functions. Here’s how you can do it.

![How to Extract DATE and TIME from TIMESTAMP: DB2](https://i0.wp.com/srinimf.com/wp-content/uploads/2025/07/add-suitable-image-edited.png?resize=1024%2C576&ssl=1)

Table of contents

1. [Extract Date from Current Timestamp](https://srinimf.com/2023/12/27/how-to-get-date-and-time-from-timestamp-in-db2/#extract-date-from-current-timestamp)
2. [Extract Time from Current Timestamp](https://srinimf.com/2023/12/27/how-to-get-date-and-time-from-timestamp-in-db2/#extract-time-from-current-timestamp)
3. [DATE and TIME Calculation](https://srinimf.com/2023/12/27/how-to-get-date-and-time-from-timestamp-in-db2/#date-and-time-calculation)
4. [Extract Function](https://srinimf.com/2023/12/27/how-to-get-date-and-time-from-timestamp-in-db2/#extract-function)
5. [References](https://srinimf.com/2023/12/27/how-to-get-date-and-time-from-timestamp-in-db2/#references)

**Get *Srinimf’s* [E-books](https://srinimf.com/e-books/) for Complex SQL queries, DB2 tough interview questions and more.**

## Extract Date from Current Timestamp

```
SELECT DATE(CURRENT TIMESTAMP) AS Date
FROM sysibm.sysdummy1;
```

## Extract Time from Current Timestamp

```
SELECT TIME(CURRENT TIMESTAMP) AS Time
FROM sysibm.sysdummy1;
```

> [Top UDEMY Courses](https://click.linksynergy.com/deeplink?id=89/9NHMn6Os&mid=47901&murl=https%3A%2F%2Fwww.udemy.com%2F&u1=srinimf)

## DATE and TIME Calculation

```
current date + 1 YEAR
current date + 3 YEARS + 2 MONTHS + 15 DAYS 
current time + 5 HOURS - 3 MINUTES + 10 SECONDS
```

These SQL queries will help you extract and manipulate the date and time from a timestamp in DB2.

## Extract Function

In DB2, the EXTRACT function is [to extract](https://srinimf.com/2017/01/21/the-best-way-extract-day-from-date-in-sql/) specific components of a date or timestamp value. Here’s an example of [how to](https://srinimf.com/2016/09/17/how-to-choose-cleverly-datetime-or-timestamp-for-table-columns/) use the EXTRACT function in a DB2 SQL query.

To extract the year from a date or timestamp:

```
SELECT EXTRACT(YEAR FROM my_date_column) AS Year
FROM my_table;
```

To extract the month from a date or timestamp:

```
SELECT EXTRACT(MONTH FROM my_date_column) AS Month
FROM my_table;
```

To extract the day from a date or timestamp:

```
SELECT EXTRACT(DAY FROM my_date_column) AS Day
FROM my_table;
```

To extract the hour from a timestamp:

```
SELECT EXTRACT(HOUR FROM my_timestamp_column) AS Hour
FROM my_table;
```

[**32 Complex SQL Queries**](https://srinimf.com/e-books/)

To extract the minute from a timestamp:

```
SELECT EXTRACT(MINUTE FROM my_timestamp_column) AS Minute
FROM my_table;
```

To extract the second from a timestamp:

```
SELECT EXTRACT(SECOND FROM my_timestamp_column) AS Second
FROM my_table;
```

Extract Date

```
SELECT EXTRACT(DATE FROM my_date_or_timestamp_column) AS Date

FROM my_table;
```

## References

- [DB2 Extract function examples](https://www.ibm.com/docs/en/db2-for-zos/11?topic=functions-extract)

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2023%2F12%2F27%2Fhow-to-get-date-and-time-from-timestamp-in-db2%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2023%2F12%2Fdate-time-calculations.jpg%3Ffit%3D1200%252C675%26ssl%3D1&description=How%20to%20Extract%20DATE%20and%20TIME%20from%20TIMESTAMP%3A%20DB2)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2023/12/27/how-to-get-date-and-time-from-timestamp-in-db2/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2023/12/27/how-to-get-date-and-time-from-timestamp-in-db2/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2023/12/27/how-to-get-date-and-time-from-timestamp-in-db2/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2023/12/27/how-to-get-date-and-time-from-timestamp-in-db2/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20How%20to%20Extract%20DATE%20and%20TIME%20from%20TIMESTAMP%3A%20DB2&body=https%3A%2F%2Fsrinimf.com%2F2023%2F12%2F27%2Fhow-to-get-date-and-time-from-timestamp-in-db2%2F&share=email)
-

### Like this:

Like Loading…