Solved

Date Stored as number in postgre database

Posted on 2009-03-31
4
624 Views
Last Modified: 2012-06-21
All,
I have a date stored in a postgre database that is stored as a number, but I am not sure about how to convert it back to a date using vb.net. For instance, 1203094800 = 2/15/2008.
Can someone show me how to convert this number back to a regular date using vb.net or a postgresql statement. This method that is used in the payroll software is very annoying, but I do not want to rewrite the whole program.
0
Comment
Question by:jpadkins49
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
jjardine earned 250 total points
ID: 24033890
This ironically works...

DateTime _date = new DateTime(1970,1,1).AddSeconds(1203094800);
0
 
LVL 22

Assisted Solution

by:earth man2
earth man2 earned 250 total points
ID: 24034576
select cast( 'epoch' as timestamp ) + 1203094800 * interval '1 second';
      ?column?      
---------------------
 2008-02-15 17:00:00
(1 row)
0
 
LVL 22

Expert Comment

by:earth man2
ID: 24034768
going the other way using extract
SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-08');
0
 
LVL 1

Author Closing Comment

by:jpadkins49
ID: 31565058
Thanks for all the help. That solved my problem.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now