dbTalk Databases Forums  

Dimension Date (Day) Issue

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Dimension Date (Day) Issue in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
dl
 
Posts: n/a

Default Dimension Date (Day) Issue - 09-08-2005 , 06:11 AM






We have a time dimension with Day as one of the levels. This seems to be
returning the incorrect day based off a date number. For example, the number
38589 represents the '25 August 2005'. When using the
DAY("dbo"."deal"."tradedate") function the day returned is 27 and not 25.
Does anyone have an idea as to why. The same with the functions DATEPART.

Thanks in advance



Reply With Quote
  #2  
Old   
Darren Gosbell
 
Posts: n/a

Default Re: Dimension Date (Day) Issue - 09-11-2005 , 08:01 PM






There is a difference between day 0 for SQL and the VBA functions

running the following in a debug window in Excel:
?format(cdate(0),"dd mmm yyyy")

Produces "30 Dec 1899"

Running the following from Query Analyser:
select convert(datetime,0)

Produces '1900-01-01 00:00:00.000' (2 days later!)

So if you are swapping between using VBA and T-SQL functions for dealing
with dates you will need to adjust for this variation between day 0.


--
Regards
Darren Gosbell [MCSD]
<dgosbell_at_yahoo_dot_com>
Blog: http://www.geekswithblogs.net/darrengosbell

In article <uSOOaYGtFHA.3528 (AT) TK2MSFTNGP15 (DOT) phx.gbl>, d@l.com says...
Quote:
We have a time dimension with Day as one of the levels. This seems to be
returning the incorrect day based off a date number. For example, the number
38589 represents the '25 August 2005'. When using the
DAY("dbo"."deal"."tradedate") function the day returned is 27 and not 25.
Does anyone have an idea as to why. The same with the functions DATEPART.

Thanks in advance





Reply With Quote
  #3  
Old   
dl
 
Posts: n/a

Default Re: Dimension Date (Day) Issue - 09-13-2005 , 06:23 AM



Thanks
Darren

"Darren Gosbell" <dgosbell_at_yahoo_dot_com> wrote

Quote:
There is a difference between day 0 for SQL and the VBA functions

running the following in a debug window in Excel:
?format(cdate(0),"dd mmm yyyy")

Produces "30 Dec 1899"

Running the following from Query Analyser:
select convert(datetime,0)

Produces '1900-01-01 00:00:00.000' (2 days later!)

So if you are swapping between using VBA and T-SQL functions for dealing
with dates you will need to adjust for this variation between day 0.


--
Regards
Darren Gosbell [MCSD]
dgosbell_at_yahoo_dot_com
Blog: http://www.geekswithblogs.net/darrengosbell

In article <uSOOaYGtFHA.3528 (AT) TK2MSFTNGP15 (DOT) phx.gbl>, d@l.com says...
We have a time dimension with Day as one of the levels. This seems to be
returning the incorrect day based off a date number. For example, the
number
38589 represents the '25 August 2005'. When using the
DAY("dbo"."deal"."tradedate") function the day returned is 27 and not 25.
Does anyone have an idea as to why. The same with the functions DATEPART.

Thanks in advance







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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.