Go Back   Rhinocerus > Newsgroup > Newsgroup comp.databases.* > Newsgroup comp.databases.ms-sqlserver

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 06-11-2008, 06:24 PM
Artie
Guest
 
Posts: n/a
Default 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.









Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 06-11-2008, 06:51 PM
--CELKO--
Guest
 
Posts: n/a
Default Re: Convert Int to Date

>> 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.
Reply With Quote
  #3 (permalink)  
Old 06-11-2008, 09:23 PM
Erland Sommarskog
Guest
 
Posts: n/a
Default Re: Convert Int to Date

Artie (artie2269@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, esquel@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
Reply With Quote
  #4 (permalink)  
Old 06-11-2008, 10:00 PM
Artie
Guest
 
Posts: n/a
Default Re: Convert Int to Date

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" <esquel@sommarskog.se> wrote in message
news:Xns9ABAF041B1687Yazorman@127.0.0.1...
> Artie (artie2269@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, esquel@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



Reply With Quote
  #5 (permalink)  
Old 06-12-2008, 07:37 AM
Erland Sommarskog
Guest
 
Posts: n/a
Default Re: Convert Int to Date

Artie (artie2269@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, esquel@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
Reply With Quote
  #6 (permalink)  
Old 06-12-2008, 11:49 AM
--CELKO--
Guest
 
Posts: n/a
Default Re: Convert Int to Date

>> 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.
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: date trouble toby dunn Newsgroup comp.soft-sys.sas 0 04-09-2006 03:20 PM
Re: date trouble nospam@HOWLES.COM (Howard Schreier Newsgroup comp.soft-sys.sas 0 04-09-2006 12:12 PM
Re: convert date to week Chang Chung Newsgroup comp.soft-sys.sas 0 06-15-2005 04:22 PM
Re: Convert invalid date format SUBSCRIBE SAS-L Stephane Newsgroup comp.soft-sys.sas 0 02-21-2005 03:45 PM



All times are GMT. The time now is 03:50 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.