473,385 Members | 1,333 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,385 software developers and data experts.

Convert Int to Date

Hi,
I have a date field stored as an INT and need to convert to a date format
mm/dd/yyyy. I'm having trouble determining what the starting date is.
min(date) = 730395
max(date) = 733189

Starting at 01/01/1900, 730395 would make the min year 3901?

Thanks for any help.



Jun 27 '08 #1
5 9379
>I have a date field [sic: columns are not fields] stored as an INTEGER and need to convert to a date format [sic: temporal data is not stored formatted] has mm/dd/yyyy. I'm having trouble determining what the starting date is. <<

Before anyone can help you, you need to understand your own data.
However, once you find out what your minimum date is, then you can
build a table with (integer, datetime) columns and do a simple look
up.

Fields have formatting (think COBOL, punch cards, etc.) while columns
have a data type (think abstract data models). The reason that you
have to deal with this crap is that someone did not know the
difference.
Jun 27 '08 #2
Artie (ar*******@yahoo.com) writes:
I have a date field stored as an INT and need to convert to a date format
mm/dd/yyyy. I'm having trouble determining what the starting date is.
min(date) = 730395
max(date) = 733189

Starting at 01/01/1900, 730395 would make the min year 3901?
As Celko said, you need to know your data, and we cannot really help you
on that point. You need to consult the documentation for this database,
or find someone who knows about it.

That said, I ran this on SQL 2008:

select dateadd(day, 730395, convert(date, '0001-01-01'))
select dateadd(day, 733189, convert(date, '0001-01-01'))

And I got back:

2000-10-03
2008-05-28

Which certainly looks compelling. But again, you need to verify.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jun 27 '08 #3
Problem is this is not my data and nobody can find any docs on this. This
is from an old version of Adapt CRM. Adapt is still around but the cheapos
I work for won't pay for support :-(

I did not think to use 0001-01-01 as a startdate since SQL was not around in
Biblical times!
Thanks for the help. You certainly got me going in the right direction.


"Erland Sommarskog" <es****@sommarskog.sewrote in message
news:Xn**********************@127.0.0.1...
Artie (ar*******@yahoo.com) writes:
>I have a date field stored as an INT and need to convert to a date format
mm/dd/yyyy. I'm having trouble determining what the starting date is.
min(date) = 730395
max(date) = 733189

Starting at 01/01/1900, 730395 would make the min year 3901?

As Celko said, you need to know your data, and we cannot really help you
on that point. You need to consult the documentation for this database,
or find someone who knows about it.

That said, I ran this on SQL 2008:

select dateadd(day, 730395, convert(date, '0001-01-01'))
select dateadd(day, 733189, convert(date, '0001-01-01'))

And I got back:

2000-10-03
2008-05-28

Which certainly looks compelling. But again, you need to verify.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx

Jun 27 '08 #4
Artie (ar*******@yahoo.com) writes:
Problem is this is not my data and nobody can find any docs on this.
This is from an old version of Adapt CRM. Adapt is still around but the
cheapos I work for won't pay for support :-(
Nevertheless, all we can offer here are guesses. Hopefully, you are able
to correlate the data with real-world information to confirm the
hypothesis.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jun 27 '08 #5
>I did not think to use 0001-01-01 as a startdate since SQL was not around in Biblical times! <<

I remember that! When I was consulting for Moses, I told him those
were lousy business rules :)

Erland has a good guess; Oracle can handle dates in the CE and BCE
ranges, so the package might have be ported over that product.
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Loi Tan Vo | last post by:
Hi, I have a text file that contains a date column. The text file will be imported to database in SQL 2000 server. After to be imported, I want to convert the date column to date type. For...
19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
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: Matt | last post by:
I would like to convert a couple informix stored procedures to SQL Server stored procedures. I have no idea how to accomplish this. Here is an example of one of the procedures I need to convert. ...
3
by: jerry.ranch | last post by:
I have a need to convert simple dates (i.e. 02/14/2005) to a number, do some math, and convert back to a date. (in a simple query). The math involves adding or substracting days, and days of the...
2
by: Franck | last post by:
Hi, 'm gettin mad about date conversion. Here is the point. Got and add-in for Excel which call functions from a web service (on a remote server) The remote server has regional settings...
1
by: abcabcabc | last post by:
I write an application which can let user define own date format to input, How to convert the date string to date value with end-user defined date format? Example, User Defined Date Format as...
17
by: Terry Jolly | last post by:
New to C# ---- How do I convert a Date to int? In VB6: Dim lDate as long lDate = CLng(Date) In C#
4
by: perryclisbee via AccessMonster.com | last post by:
I have dates of service for several people that range all over each month. ie: patient had dates of service of: 7/3/2006, 7/24/2006 and 7/25/2006. I need to create a new field via a query that...
8
by: deepak_kamath_n | last post by:
Hello, I have the following scenario: 1. My application receives the date from another application as a string 2. The other application is running in a different time zone as compared to my...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.