Solved

Date Stored as number in postgre database

Posted on 2009-03-31
4
635 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with opening combobox using VB.NET. 3 25
Error message when using PrintSocket.Send 7 18
Looping through datagridview and dataset ? 6 24
Code enhancement 4 21
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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