Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Date Time Statement

Author  Topic 

JVisconti
Starting Member

47 Posts

Posted - 2009-09-17 : 12:22:40
I have a SQL statement that currently reads:

(CASE CLOSEDATETIME
WHEN '1899-12-30' THEN NULL
ELSE
(CAST(DATEPART(mm,CLOSEDATETIME) as VARCHAR)+'/'+
CAST(DATEPART(dd,CLOSEDATETIME) as VARCHAR)+'/'+
CAST(DATEPART(yyyy,CLOSEDATETIME)as VARCHAR)) END) AS TicketCloseDate,

I this is what is currently being used to get date/time values from a View that has been created. The view is being pulled into Excel and I have run into a Date/Time math problem and I am using formulas in Excel to make up the difference. One of the formulas I am using looks like this:

=IF(ISBLANK(Table_SQL01_databasename_TicketStatistics[[#This Row],[HistoryFirstResponse]]),0,(Table_SQL01_databasename_TicketStatistics[[#This Row],[HistoryFirstResponse]]-


What I need is a statement I can put into the SQL View Query to give that information without rewriting a formula in Excel to format the Date/Time.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-17 : 12:48:54
Sorry but I can't see any relation between the posted formula and that part of sql statement.
I can see your sql gives NULL or 9/17/2009 as TicketCloseDate but what is the problem?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

JVisconti
Starting Member

47 Posts

Posted - 2009-09-17 : 13:03:35
Basically when I see the spreadsheet in Excel I would like the SQL Query to be able to pull only the Date or only the Time from the database without any additional formatting such as:

(CAST(DATEPART(mm,CLOSEDATETIME) as VARCHAR)+'/'+


Trying to eliminate the CAST and VARCHAR to make the information show correctly in Excel without a formula.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-09-17 : 21:57:52
quote:
I this is what is currently being used to get date/time values from a View that has been created. The view is being pulled into Excel and I have run into a Date/Time math problem and I am using formulas in Excel to make up the difference. One of the formulas I am using looks like this:

=IF(ISBLANK(Table_SQL01_databasename_TicketStatistics[[#This Row],[HistoryFirstResponse]]),0,(Table_SQL01_databasename_TicketStatistics[[#This Row],[HistoryFirstResponse]]-

what actually is the problem you had the date in excel ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

JVisconti
Starting Member

47 Posts

Posted - 2009-09-22 : 09:12:18
I am just trying to eliminate the need for the formula in Excel and just have the information displayed straight from the query. As it stands now, the formula's are a separate piece, while related to the query, not pulled from the query.
Go to Top of Page
   

- Advertisement -