473,395 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to convert Milliseconds to Date in DB2?

Hi all,

I have a date which is represented by the number of milliseconds since January 01, 1970. I need to change this back to DATE format. Is there any built in function in DB2 to do the needed conversion ?

In Oracle i was able to do the conversion by the following statement.

select to_char(to_date('01/01/1970','mm/dd/yyyy'),'mm/dd/yyyy') + milliseconds/86400000) from dual;

Note: In the above sql statement, milliseconds is the no: of milliseconds of the desired date.
Dec 20 '06 #1
2 24073
bousch
1
In DB2 it would be:

Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.   DATE(
  3.     TIMESTAMP('1970-01-01','00.00.00')
  4.     + (millisecondfield/1000) seconds     )
  5. from ...
  6.  
Hi all,

I have a date which is represented by the number of milliseconds since January 01, 1970. I need to change this back to DATE format. Is there any built in function in DB2 to do the needed conversion ?

In Oracle i was able to do the conversion by the following statement.

select to_char(to_date('01/01/1970','mm/dd/yyyy'),'mm/dd/yyyy') + milliseconds/86400000) from dual;

Note: In the above sql statement, milliseconds is the no: of milliseconds of the desired date.
Mar 5 '08 #2
docdiesel
297 Expert 100+
Hi,

if you need a DATE value, you could calculate directly in days, too:

Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.   ( date('1970-01-01')  +
  3.     (millisecondfield / 86400000) days
  4.   ) as calculated_date
  5. FROM
  6.   ...
If you should try both, please let us know which one works faster.

Regards,

Bernd
Mar 6 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
1
by: ABC | last post by:
How to convert a date string to datetime value with custom date format? e.g. Date String Date Format Result (DateTime value) "05/07/2004" "MM/dd/yyyy" May 7, 2004 "01062005" ...
1
by: h_ghanaty | last post by:
how i can convert gregorian date to jalaly(Iran date) with vb.net
1
by: Raja | last post by:
Hi Anyone has any idea of how to convert Julian Date (eg. 12744057862..) to a VB.NET date time. Thanks in advance.
1
by: Sam | last post by:
How do I convert Julian Date to Calendar Date in ASP.Net 1.1 based on following guideline found at Internet? To convert Julian date to Gregorian date: double JD = 2299160.5; double Z =...
4
by: Daniel Kaseman | last post by:
How do I convert a date into a serial number? (I'm trying to enter a FROM date and a TO date, then make my PROGRESS BAR show how close I am to the TO date.) get it? I know that MS Excel...
2
by: Kakishev | last post by:
I have a problem at how best to convert a Date into a text field and keep the format dd/mmm/yyyy (01-FEB-2007). The problem is that dates are imported from SQL into an access front end Database....
3
by: vunet.us | last post by:
What is the best method to convert milliseconds (after midnight January 1, 1970 GMT) to formatted time example: 972798180000 ==10/18/2000 14:08:11
3
by: lyne_asp | last post by:
Please help me to convert excel date to asp date. Here is my code objConnEx.open "Provider=Microsoft.Jet.OLEDB.4.0;Data...
1
by: smdmca | last post by:
I have Julian date, I want to convert it into date. Is there any function in MySql to convert Julian date to date eg- Julian Date- 2455116 Date - Oct - 12, 2009
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.