.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Post New Web Links

want to display 24 hours time and date with datatype Datetime (Not String) in SSRS

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :Sql Server
 

Hi All,

I want to display 24 hours time and date in SSRS & for that I am using Format(now,"MM/dd/yyyy HH:mm:ss") but I am using this expression in Parameter, where I need to define datatype of that parameter as DateTime, not string. For Expression Format(now,"MM/dd/yyyy HH:mm:ss"), If I use DateTime datatype, It is showing error but working with String datatype.

For example:

I have parameter To Date  and value of this parameter should be 10/11/2010 13:09:16 (To Date: 10/11/2010 23:09:16) , not in AP or PM format and datatype of this parameter, want to keep DateTime that I can select value from Calender.

Please suggest me how I can achieve this?. I don't want to do it in stored Procedure side, want to do it in report side.


Thanks Shiven:)


View Complete Post


More Related Resource Links

Expression for 24 hours time and date in SSRS

  
Hi Guys, What is the expression for  displaying 24 hours time and date in SSRS? Is this the format: =Format(now, "MM/dd/yyyy HH:mm:ss")?Thanks Shiven:)

string to datetime conversion using date parameters in SSRS

  

Hello, I have a database field that I am pulling that is type string, but the format of each value is mm/dd/yyyy.  I want to convert this to a datetime format (minus the time) so that i can compare this value to a parameter date range (begin date and end date) that are type datetime so that i can use the calendar control in my report.  i've tried in my select statement to use select.....convert(datetime, stringfieldname, 101), but I get an error that says "Conversion failed when converting datetime to character string". 

I am also open to converting the datetime parameters to strings to do the comparison, but not sure the best way to do this either.

thanks!


Essential SQL Server Date, Time and DateTime Functions

  
The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any formatting considerations at all.

Date Time for Display

  
Hi AllI want to display time on Y axis and days on  x axis.I want to dispaly 12:00 AM,11:00 AM...11:59 PM.  on Y axis.I want function to create sequence like thatand on X axis display week like 6-sep,7-sep,..11-sep.can you give me the function for this.how i can create these

Convert a string (from xml) into date time

  
Is there a simple command to take this string: 2010-09-09T17:00:00.000Z and turn it into a date time? It is a date time value that is passed to us in an xml document, it has a type of 'unitless', when I read it I need to set a dateTime variable to this date and tim, I can parse it, but perhaps there is a simple single command that is already written for just such a thing. Thanks. 

Conversion failed when converting date and/or time from character string. SQL 2008

  
The below simple query giving me the "Conversion failed when converting date and/or time from character string." error. Because I've  datatype of "Created" & "Finished" column in below table VARCHAR(100) select * from dbo.mytable where CONVERT(datetime,Created) >= convert(datetime,'9/1/2010') and CONVERT(datetime,Finished) <= convert(datetime,'9/9/2010') In my table i've date stored in below varchar(100) formats. examples: '2010-09-01 11:14:54.000' --Created '2010-09-03 13:43:37.000' --Finished I tried to convert the date in following way but NO luck??? Could you please advise me??? convert(datetime,convert(varchar,convert(datetime,Created),101)) >= convert(datetime,'2010-09-01') and convert(datetime,convert(varchar,convert(datetime,Finished),101)) <= convert(datetime,'2010-09-09') Much appreciated your help!! thanks, pbrathod pbrathod

Conversion failed when converting date and/or time from character string. SQL 2008

  
The below simple query giving me the "Conversion failed when converting date and/or time from character string." error. Because I've  datatype of "Created" & "Finished" column in below table VARCHAR(100) select * from dbo.mytable where CONVERT(datetime,Created) >= convert(datetime,'9/1/2010') and CONVERT(datetime,Finished) <= convert(datetime,'9/9/2010') In my table i've date stored in below varchar(100) formats. examples: '2010-09-01 11:14:54.000' --Created '2010-09-03 13:43:37.000' --Finished I tried to convert the date in following way but NO luck??? Could you please advise me??? convert(datetime,convert(varchar,convert(datetime,Created),101)) >= convert(datetime,'2010-09-01') and convert(datetime,convert(varchar,convert(datetime,Finished),101)) <= convert(datetime,'2010-09-09') Much appreciated your help!! thanks, pbrathod pbrathod

how to retrieve various date format from datetime datatype column

  

first table

Area_code (varchar)    Loan_date (datetime)

USA                             9/21/2009  12:00:00 AM

CAN                            10/22/2010  12:00:00 AM

ARG                            12/23/2009 12:00:00 AM

Second table

Area_code (varchar)    Date_format(varchar)

USA                             dd/mm/yy

CAN                             yy.d.m

ARG                            yy'?'d'?'m'?'

I want to add Loan_date column in second t

how to retrieve various date format from datetime datatype column

  

first table

Area_code (varchar)    Loan_date (datetime)

USA                             9/21/2009  12:00:00 AM

CAN                            10/22/2010  12:00:00 AM

ARG                            12/23/2009 12:00:00 AM

Second table

Area_code (varchar)    Date_format(varchar)

USA                             dd/mm/yy

CAN                             yy.d.m

ARG                            yy'?'d'?'m'?'

I want to add Loan_date column in second table and nee

SQL error: Conversion failed when converting date and/or time from character string.

  
I hope someone can advise on the issue I'm having.

This SQL worked beautiful until I added in @startdt and @enddt and this section >> AND [Selldate] BETWEEN ' + @startdt + ' AND ' + @enddt + '

By adding in this condition, I now get the following error:

Msg 241, Level 16, State 1, Line 8
Conversion failed when converting date and/or time from character string.

I have tried changed variables to type = date and various iterations of date formatting, casting with no success. The date in the table is clean as a whistle.

(The CONVERT function is being used in setup for a PIVOT SQL which needs  VARCHAR for column headers)

Thanks in advance for your help, 
JR

declare @itemID varchar(20)
declare @startdt varchar(12)
declare @enddt varchar(12)
set @itemID = ''
set

getting time and date from datetime field in javascript

  

Hello guys, I need to get hours from the difference between two datetime fields. I wrote the javascript which will get the date from datetime field.

But its not getting the correct time that entered on date time field. Its defaultly getting the current time on my system.

So do you guys have any idea. How to get time from date time fields. and how calculate hours between two datetime fields using javascript.


Display date headers in SSRS reports

  

Hi All,

I have a report to display sales figure for the last 3 days including current date. That means whenever the report is generated it should start the date column with the current date and the previous 3 days data. I have the query ready to pull the data. But I am not able to generate the column headers in date format. Below is my report format for your reference...

  10/4/2010 10/3/2010 10/2/2010 10/1/2010
Product A

display only the date (not time) from a sqlserver date field in dynamic data

  

I have some Date fields defined in my sqlserver database but these display with a time part as well (00:00:00).

how do i esnure that only the date part is displayed and not this redundant time?

John 


Separate Date and Time report parameters in SSRS 2005

  

Hello,

Is it possible to declare separate report parameters in SSRS 2005 as Date and Time?

I want the user to be able to enter a date and a time.

When I declare the parameters in my stored procedure as datetime, in SSRS the parameter just shows as a Date only.

thanks.


Time Dimension for YTD using assigned Month and Year integers without Date datatype

  

Hi, most time dimensions are setup using a base Date field in the fact table, and they have plenty of issues for time analysis as it is. However my fact sales records have the time aspect assigned by pre-calculated periods, because depending on various factors, monthly final invoices are all raised on varying days (usually 2nd friday of month but can change). The monthly period is therefore not a straight calendar month. Probably a very common scenario.

So, the invoicing system already assigns the year (ie 2009, 2010, 2011) and monthly period (1, 2, 3 ... 12 with 3 representing march, even though that might represent 13th march to 9th april) and I want to use those as Time dim so we can do YTD, growth-on-prev-year etc.

It looks like its best to setup 2 Dimensions to link to 2 DataColumns/Attributes in the Fact table (say, FYear and FMonth, both integers). That way I can assigned attribute names like March to key column 3. If I combined them into 1 dimension with both fields making up a single key column, would have to either repeat the month names or link it to another Star schema I believe.

I can use the Add Business Intelligence wizard to make the Dimensions into Time ones instead of regular but I'm still not totally sure if this is the best structure/method and once done, how to use the YTD calcs to show in the cube browser (and my MDX knowle

Seperate DateTime into Date column and Time column in query

  

This is probably a simple question but here it goes.

First off let me state that the naming of these columns is not by my choice nor can I change them.  We purchased some software that automatically does the naming conventions for it's fields (Sample1).

I have a table with 2 columns in it:

Sample1                      Time is in GMT Time

Time           DateTime, PK        

LMP             Float

Table 2:

ABC_Price                   (Day, Hour) is in EST Time

Day               SmallDateTime   PK

Hour              TinyInt       PK

MW                Decimal(7,3)

Price              Money

 

What I need to do is split the Ti

SSRS Date Time value in parameter, pass SP

  

Hello,

I had a strange problem last week in few SSRS Reports, scheduled in a report server.

SSRS Report

This report uses StartTime and EndTime parameters defined as 'String' data type and the default value is populated from a dataset. (Format of String, 10/29/2010 6:00:00 AM)

The report uses a stored procedure (stored_proc) to pull the report data from the SQL Server database for display in the report.

The SP stored_proc uses 3 input parameters named below
@par1 nvarchar(4000)
@StartTime nvarchar(20)
@StopTime nvarchar(20)

It was worked well for the past one year, but suddenly it stop run in production and throws the below error.

System.Data.SqlClient.SqlException: Conversion failed when converting datetime from character string.

When we look at the SP, the below line of code throws the error(CreateDate is the database table column).

Where (CreateDate >= @StartTime AND CreateDate < @StopTime ) 

From the profiler log, we understand that the below statement was triggered by SSRS.

exec stored_proc @par1=N'4',@StartTime=N'10/29/2010 6:00:00 AM',@StopTime=N'10/29/2010 6:00:00

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend