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


Post New Web Links

problems with converting string to value from a KPI value

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

Hi,

I have problems to formating the Value and Goal expressions from a KPI. When processed, the values are shown as a string in excel. How can i format this that excel will interpret this as a Numerical value.

P.s. when using only Cdbl, excel interpret this as a value but i need the formating on top of that.

 

Value Expression:

Format(Cdbl([Measures].[Asset Bookvalue balance - Todate] - [Measures].[Total Maturing Principal - Todate]), "#,##0 ;(#,##0")

Goal Expression:

cdbl([Measures].[Asset Bookvalue balance - Todate])

Status Expresion:

Case

When IsEmpty(KpiValue("Asset Loan Exposure")) or KpiGoal("Asset Loan Exposure")=0

Then Null

 When 

  KpiValue("Asset Loan Exposure") /KpiGoal("Asset Loan Exposure") >= 0.20

   Then 1

 When

  KpiValue("Asset Loan Exposure") /KpiGoal("Asset Loan Exposure") < 0.20 And 

  KpiValue("Asset Loan Exposure") /KpiGoal("Asset Loan Exposure") >= -0.20

   Then 0

  Else-1

End





View Complete Post


More Related Resource Links

WebMatrix conversion failed when converting from a character string to uniqueidentifier?

  

I am trying to retrieve xml from a small function in my .cshtml page. Its throwing me an error. This however, runs fine in a console/form environment.

It takes 3 parameters and 1 exception.

myDll.GetXML(year, username, uniqueidentifier, out ex);

When I run this page I get the error, "Conversion failed when converting from a character string to uniqueidentifier."

Or a stack of.

System.Data.SqlClient.SqlException (0x80131904): Conversion failed when converting from a character string to uniqueidentifier.

   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)

   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()

   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)

   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()

   at System.Data.SqlClient.SqlDataReader.get_MetaData()

   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBeha

Problems converting VS 2003 project to VS 2008

  

Hi!

I'm having problems converting a VS 2003 project to VS 2008 (tried 2005 as well, same problem). There are several problems;
a) I don't have VS 2003 installed.
b) The project is a web service, however I'm not sure what type of VS project it was created as.
c) The general knowledge about the project setup is..slim.

I get a error message using the conversion wizard, however, I'm not familiar with the tool and I cannot quite find any good information on Google for it, so I am left with a error message I do not understand.

Conversion Issues - myProject.csproj:
Unable to open the Web site 'C:\local\path\to\project\myProject.csproj'. The Web site 'C:\local\path\to\project\myProject.csproj' does not exist.

The web service is not intended to run on the dev machine, it is copied to a test or a prod server. However, I do not know how this was done previously. I'm thinking that in order to convert, it has to access the server on which it should run (which is set somehow in a config maybe). But that doesn't actually make any sence..

If anyone could shed light on this, I would really appreciate it.

Thank you.


Convertion failed when converting datetime to String

  
DECLARE @usr datetime SET @usr = user+'::Date' IF NOT EXISTS (SELECT 'X' FROM table WHERE Name = 'File' AND CONVERT(varchar,DateAdd, 101) = CONVERT(varchar, getdate(), 101)) BEGIN INSERT INTO table (Code, Name, Date) VALUES ('DD', 'File',@usr) END the date will be created by another process and its value will be loaded in the variable DATE. I'm calling that variable here. I;m getting the error Convertion failed when converting datetime to String. how to resolve this..??

Convertion failed when converting datetime to String

  
DECLARE @usr datetime SET @usr = user+'::Date' IF NOT EXISTS (SELECT 'X' FROM table WHERE Name = 'File' AND CONVERT(varchar,DateAdd, 101) = CONVERT(varchar, getdate(), 101)) BEGIN INSERT INTO table (Code, Name, Date) VALUES ('DD', 'File',@usr) END I;m getting the error Convertion failed when converting datetime to String. how to resolve this..??

Converting Date to String and Formating it Linq to SQL

  
Hello I have problem in converting date to string I am using cstr(p.tripstart) , which is returning Date as 12 Aug 2010 12:AM   I need to make formating   This is my code : Dim db As New TripsLinqDataContext Dim listtrips = (From p In db.Trips _ Group Join c In db.Countries On p.TripCountryID Equals c.TripCountryID Into countrylist = Group _ Select New With {.Tripdetails = p.TripDescription + " - " + p.TripCityList + " - " + CStr(p.tripstart) + " - " + CStr(p.TripDays), _ .Tripid = p.TripID}).ToList tripboxlist.DataSource = listtrips tripboxlist.DataTextField = "Tripdetails" tripboxlist.DataValueField = "Tripid" tripboxlist.DataBind()     Regards  

Replace string in xml without converting to varchar using SQL Server

  
We have a xml datatype in SQL server which gets a xml file loaded into it. We want to replace some of the content in the xml datatype, but are running into problems converting from xml to varchar(for manipulation purposes), back to xml to output. Does anyone know of a way to replace xml without converting to varchar?Thanks in advance

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

Converting string to DateTime

  
Hello, I am trying to figure out the best way to convert a string object into a DateTime with only using the year.I have something like:Date Time HSYear = DateTime.ParseExact(HighSchoolyear, "yyyy", System.Globalization.CultureInfo.CurrentCulture); But it is still giving a "String was not a recognized as a valid DateTime."In the full context, I have a webpage with a formview on it and within the formview is a TextBox control that is taking a user input such as "1999"  then an ObjectDataSource picks it up and runs it through a BLL. And within the BLL is where I am trying to convert it before it gets inserted into the database.

converting string to datetime and then to shortdate?/

  
Hi,I have a field (varchar) field that holds date.  Some data was transferred to this column but the transferred data was a timestamp (datetime in the format of say 10/26/2009 4:54:13 AM).  Now, I need to modify the new table to only contain 10/26/2009.  How can I write a statement to delete the time leavin gonly 10/26/2009??  I can use trim function but the # of characters vary as the date might be 1/10/2010 12:50:00 PM, etc....?thanks .

converting a rdr object to a string

  

I inherited some code and I need to change a line so that instead of testing to see if the value in a table column is not null, it also tests to see if the value is not empty.

The existing line is:

if (rdr["InnLinkURL"] != null)


"InnLinkURL" is the name of the column being tested.

I thought a solution could be something like:

if (String.IsNullOrEmpty(InnLinkURL) == true)

Not sure how to convert the object to a string, though.

public static string ToString(
 object value
);


If someone could show me the proper syntax I'd be grateful.

As an alternative, I tried this also but it doesn't seem to work (no errors, just doesn't return true)

if ((rdr["InnLinkURL"] != null) && (rdr["InnLinkURL"] != ""));




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

converting a hex string to an IP address

  

i have no idea which forum to post this to, thought i would start here.  i have exported log files from TMG firewall and brought them into sql2008r2.  i have a view that shows me the logtime, ClientIP, and username fields.  So far so good.  The problem is that the IP address field looks like this:  0A370D16 - which, if adjusted, would be 0a.37.0d.16 = 10.55.13.22.  The field is a string - how can i manipulate the select statement to make it look like an ip address (select blahblah as SourceIP from...)?

 

thanks


string not converting in datetime format

  

hi to all,

 i'm developing a website. i have a registration form where user can registered with this website.

this have a birthdate field for store user's birthdate.that is a textbox.

here is my code.

protected void submitbtn_Click(object sender, ImageClickEventArgs e)
{
System.Globalization.CultureInfo en = new System.Globalization.CultureInfo("en-GB");
li.fname = firstname.Text;
li.lname = lastname.Text;
li.gender = gender.SelectedItem.Text;
li.date = Convert.ToDateTime(birthdate.Text,en); //getting error here
li.address = addrs.Text;
li.contactno = contno.Text;
li.countryid =Convert.ToInt32( dropcontry.SelectedValue);
li.stateid = Convert.ToInt32( dropstate.SelectedValue);
li.cityid =Convert.ToInt32( dropcity.SelectedValue);
li.emailid = prmrmailid.Text;
li.username = createuserid.Text;
li.password = createpassword.Text;
li.secutityque = dropsecque.SelectedItem.Text;
li.securityans = secanswer.Text;
li.registrationform(li);

li.lastselect();
int a = li.personid;
li.personid= a;
li.insrtusername(li);
li.lastselect();
int p = li.personid;
li.questioninsrt(li);
}

Conversion failed when converting datetime from character string. SQL Server @StartDate as datetime

  

Hi,

Can you please help me on this?

When I try to pass my parameter it doesn't work. See below is my code :

 

declare @SQL Varchar(4000)

declare @CRM_FilteredAppointment nvarchar(2000)

declare @CRM_FilteredSystemUser nvarchar(2000)

declare @StartDate datetime

declare @EndDate datetime





set @CRM_FilteredSystemUser = 'Select * from FilteredSystemUser'

set @StartDate = '20080101'

set @EndDate = '20100101'



set @CRM_FilteredAppointment = 'SELECT activityid, participationtypemask 

FROM FilteredAppointment 

WHERE FilteredAppointment.eu_calltype = 2

AND FilteredAppointment.statecode = 1

AND FilteredAppointment.scheduledend >= DateAdd( month, -1, GetD

Connection string problems using domain name

  

Presume that the following all point to the same physical server:

  • Host name:  MyServer
  • IP:  10.61.734.321
  • Domain name: oakl.abt.gov

Using the first two naming methods works in my SSRS Report Manager connection string, the last one does not.  So in the following the first two work, the third one does not:

  • Data Source=MyServer;Initial Catalog=ZipCubes
  • Data Source=10.61.734.321;Initial Catalog=ZipCubes
  • Data Source=oakl.abt.gov;Initial Catalog=ZipCubes

The last connection string yields the error message:  Cannot create a connection to data source

The problem is given the widely varied network topology, not every end user can resolve the server name and/or IP address, only the domain name.  Any tips then on how to use that in the connection strings?  Thanks.

 


Conversion failed when converting from a character string to uniqueidentifier

  

Hi all,

 

I am trying to match a username to a userid which are in 2 different sql tables. Here is my select statement:

SELECT     aspnet_Users.UserName
FROM         aspnet_Users INNER JOIN
                      aspnet_starterkits_Projects ON aspnet_Users.UserName = aspnet_starterkits_Projects.ProjectManagerId

When I run this i get an error message: "Conversion failed when converting from a character string to uniqueidentifier"

Is there anyway around this? Or a different select statement etc?

 

Thanks!


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