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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Problem with date type

Posted By:      Posted Date: September 17, 2010    Points: 0   Category :Windows Application
hi i receive this date: `9/20/2010 3:32:32 PM` i need to convert to datetime. i try:     DateTime DateFrom = DateTime.ParseExact("9/20/2010 3:32:32 PM", "dd/M/yyyy", CultureInfo.InvariantCulture);                     but i get error: `String was not recognized as a valid DateTime.` in my computer the region is: `Hebrew (Israel)  dd/MM/yyyy for short date and hh:mm for short time` how to fix it ? thank's in advance

View Complete Post

More Related Resource Links

Conversion from string to type 'Date' is not valid



Im receiving a strange error Error Message: Conversion from string "15/08/2010 22:21:35" to type 'Date' is not valid.

I know this is generally down to cultural date formats etc, however the reason this is strange is it just randomly occured twice in the last week, the website has been running since october and nothing has changed,

The error constantly occured until the IIS was reset and recompilled the site, its been running fine since, however im just trying to figure out what could cause such an error to occur.

I've narrowed it down to a line of code which is:

bktime = DReader.Item("Bktime").ToString

bktime = Year(CDate(bktime)) & "-" & fmt(Month(CDate(bktime)), 2) & "-" & fmt(Day(CDate(bktime)), 2)

Has anyone else encountered this randomly occuring and is there anything i can put in place to prevent this in future?



How can I solve this problem?::Compiler Error Message: CS0433: The type 'CrystalDecisions.Web.Cryst


I upgraded my web application from visual studio 2003 to 2008. When I want to create a report in visual studio 2008 and receiving this error at runtime. I am able to compile but when runnning thats when I am getting this error.

How can I solve this problem? please help.

Compilation Error

Server Error in '/IRPSDEV' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0433: The type 'CrystalDecisions.Web.CrystalReportViewer' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.Web\10.5.3700.0__692fbea5521e1304\CrystalDecisions.Web.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\irpsdev\9e97e0a9\94a2ecd\assembly\dl3\151eb571\00df56e1_6064c201\CrystalDecisions.Web.DLL'

Source Error:

Line 161:        
Line 162:        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
Line 163:        private global::CrystalDecisions.Web.CrystalR

DataContractJsonSerializer: Problem when deserializing the Date

Sorry for cross-posting. I posted the same question on the Silverlight forum, but it has not received a single answer yet. The majority of folks there must be more interested in UI than in more fundamental stuff.     Hello everyone! Let's say we have the folllowing POCO classes: public class PocoObject : List<PocoPropertyData> {     public PocoObject() {}     public override string ToString()     {         var parts = new List<string>();         foreach (var pd in this)             parts.Add(string.Format("{{N=[{0}], Type=[{1}], V=[{2}]}}", pd.N, pd.V == null ? typeof(object) : pd.V.GetType(),  pd.V));         return string.Join(",", parts);     } } public class PocoPropertyData {     public string N { get; set; }  // the property name     public object V { get; set; }  // the property value } As you can see, the PocoPropertyData can hold value of any type. When I execute the following code in both .NET 4 application and Silverlight 4 application: ========================================================= var poco = new PocoObject {       { new PocoPropertyData { N = "DateTimeField", V =  Da

sove this type of problem what to do?

Hi ... Crystal Report Issue plz help ... I have developed an asp.net application with crystal report using visual studio 2005 n built in crystal report version 10 on win xp machine x86. its working fine in my PC. But the production server is 64bit OS windows server 2008 n IIS 7. My application is working fine , but am getting error in all crystal report page. They have installed Crystal report X64 in their server. Due to version conflict the report page not working. But i tried in 64bit Win 7 OS with juz crystal report x86 installed. Its working fine. I tld this to my service provider, but they are not ready to install crystal report X86 due to shared hosting. Plz help me , wat step i must take in order to resolve this issue ....

Problem casting date

I'm developing a Windows Forms app using VS 2008 with a SQL Server 2005 database. I've got search form where users can search for data by entering one or two criteria. One of these is a date which corresponds to a date field in my database. The user clicks on a button, which feeds the criteria into a stored procedure. The results are displayed in a datagridview control. While the functionality works well with the non-date criteria, whenever a date criteria is used on it's own a cast error is raised ('Conversion failed when converting datetime from character string.') I've tried lots of ways of casting the date (formatting using left, right and mid finctions, using the substring function etc) but still can't get it to work. Code and SQL are shown below. Does someone know where I've gone wrong? 'DateAssayRequested' is the date in question. <vb> 'set up and initialise connection conn = New SqlConnection(etc) comm = New SqlCommand comm.Connection = conn comm.CommandText = "SPSearch" comm.CommandType = CommandType.StoredProcedure 'create input parameters, set types and values param = comm.CreateParameter param.ParameterName = "@assayid" param.Direction = ParameterDirection.Input param.Value = txtLabNo.Text

Date validation problem modelstate.isvalid is false

In my view i am formatting the date as follows<%= Html.TextBox("MemoDate", string.Format("{0:dd/MM/yyyy hh:mm}", DateTime.Now),new{ @readonly = true })%> In controller ModelState.IsValid become false as my current culture culture {en-US} doesn't match with the format of date.

Basic data type problem with database insert

Hi,I'm trying to write some values into a database, but I think there's an issue with the data types.  Here's what I've got: public static string Hello(string pageId, string inOut) { string itemId = ""; string period = ""; var cookie = HttpContext.Current.Request.Cookies["visitorGUID"].Value; SqlConnection conn; SqlCommand comm; conn = new SqlConnection(GlobalSettings.DbDSN); comm = new SqlCommand("INSERT INTO myTable (memberGUID) VALUES (@memberGUID);", conn); comm.Parameters.Add("@memberGUID", System.Data.SqlDbType.Text); comm.Parameters["@memberGUID"].Value = cookie; try { conn.Open(); comm.ExecuteNonQuery(); return "Item added: cookie = " + cookie + " / pageId = " + pageId + " / inOut = " + inOut + " / pageId = " + pageId + " / itemId = " + itemId + " period = " + period; } catch { return "Item caught: cookie = " + cookie + " / pageId = " + pageId + " / inOut = " + inOut + " / pageId = " + pageId + " / itemId = " + itemId + " period = " + period; } finally { conn.Close(); } } At the moment I'm just trying to insert the value of the cookie into the database as a test.  It works fine when I

Problem with date values in data-driven subscription reports

Hello together, I have a question in regards of data-driven subscription report. I already have an ad-hoc report in place which can be customized by date etc. I now want to run these reports with a subscription. My challenge is now that I don't know how I can pre-define the date. I basically want the start date of NOW() and the end date 7 days in the past. I was looking around but did not get any clue where and how I have to configure it the way it works. I found this thread but honestly do not understand it well... :( http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/fb48fd15-09dd-4f5f-a09f-d92bf304c1a2 Can someone help me out please? M.

Problem with Dimension of type Account

Hi, I have a simple fact table where I have a dimension time and a dimension of type acount. The fact table looks like this FinanceKey AccountKey ProfitCenterKey DateKey DateAlternateKey ScenarioKey Amount 1 11 5 7308 2010-01-01 1 131 2 11 3 7308 2010-01-01 1 62115 3 11 0 7308 2010-01-01 1 27626 4 11 6 7308 2010-01-01 1 12 5 11 2 7308 2010-01-01 1 74316 6 11 7 7308 2010-01-01 1 14 7 11 5 7339 2010-02-01 1 147 The account dimension looks like this AccountKey AccountAlternateKey ParentAccountKey AccountName_en AccountName_de AccountType Operator CustomMembers ValueType CustomMemberOptions 1 1 NULL Statistical Accounts Statistische Kennzahlen Statistical ~ NULL Units NULL 11 11 1 Customer Count Anz. Kunden Balances ~ NULL Units NULL If I browse my cube I get no data for the measure amount. When I remove hte parent Account "Statistical Accounts" and ste the parent of "Customer Count" to NULL I will get the correct Customer count. Any idea?

Problem displaying Date from Sql table on Calendar Control

Hi, I am displaying Event dates from SQL table on Calendar Control in ASP.NET. Also, I have GridView Control which shows event details when certain date is clicked on calendar control. But I have a problem as not all dates are displaying properly. Strangly enough only dates which have same month and day date are displayed. For example: It shows ok dates such as 08/08/2010, 09/09/2010, 10/10/2010 etc. If I click on the date which in SQL table exists as 11/25/2010 or 12/15/2010 etc (no matching month/day numbers) it shows error message saying: "System.Data.SqlClient.SqlException: Conversion failed when converting date and/or time from character string."  Follwoing is my code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.Sql; using System.Runtime.Remoting.Messaging; using System.Configuration; using System.Data.SqlClient; using System.Data; using System.Drawing; public partial class Test_Calendar : System.Web.UI.Page { SqlConnection mycn; SqlDataAdapter myda; DataSet ds = new DataSet(); DataSet dsSelDate; String strConn; private void Page_Load(object sender, System.EventArgs e) { strConn = "Data Source=mydatasource;Initial Catalog=DBname;Persist Security I

Date formate problem

Hi I have faced one problem with processing date field from xml file. i have read RSS site and get date field from this site and parse that date field using below code i got pubDate field from xml like : <pubDate >06 Sept 2010 09:15:01 +0300</pubDate > datefield = DateTime.Parse(xmlfile.Element("pubDate").Value.Replace("\n\r", "").Replace("\r\n", "").Replace("\n", "").Replace(" Sept "," Sep ").Trim(), FinishCulture.DateTimeFormat, DateTimeStyles.AdjustToUniversal).AddHours(3).ToString("dd.MM.yyyy HH:mm:ss"),   I have face this problem because of month format "Sept". i have also implement this functionality with other RSS site they working fine with above code as they return date like : <pubDate >06 Sep 2010 09:15:01 +0300</pubDate > So, the problem is with month name Sept - Sep. can you please tell me how can i handle "Sept" month name format.   Thanks Nikunj Padaliya  

Date Time interval Problem

Hi I have a problem in which i have to check the time interval to the another which is already exist in Database table.For Exp.10:00 am  To 11:00 am i add an Event now if user insert the again this time interval  it's throw the error message.if user want's to edit this event For exp.10:15 am to 11:00 amhow do this.Thanks

Problem with AJAX - " Could not load type 'System.Web.UI.ScriptReferenceBase' from assembly 'Syst

Hi., I'm using Visual Studio 2008 and i downloaded the toolkit from Codeplex, I downloaded the zip file which i've marked red in the below link.. This is my code, <form id="form1" runat="server"> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager> <asp:Panel ID="Panel1" runat="server"> Hi Simbu AJAX Works Fine ! </asp:Panel> <asp:RoundedCornersExtender ID="RoundedCornersExtender1" runat="server" TargetControlID = "Panel1" Radius = "6" BorderColor = "#FBB117" Corners = "All" > </asp:RoundedCornersExtender> </form> & this is the error i get, " Could not load type 'System.Web.UI.ScriptReferenceBase' from assembly 'System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' " I saw this post, http://forums.asp.net/p/1273185/3439540.aspx and i changed my TOOLSCRIPTMANAGER into SCRIPTMANAGER & now i get this error ! and now c what this post says... http://forums.asp.net/t/1529516.aspx NOW WOT AM I SUPPOSE TO DO ??? PLZ GUIDE ME ! I'm struck up with this since 2 days....

StrToMember problem with todays date.

Hi, I want a calculated member who will give me the bookvalues for todays month. When i run these two scripts (variables and hardcoded examples) in SQL server management studio the result are shown for both scripts no problem there: SELECT {[Measures].[Asset Bookvalue balance]} ON 0,  [MSN].[Asset].[Asset] on 1 from CMSX_DWH_OLAP  where {StrToMember("[Book Value Start Date].[Year - Quarter - Month].[Month].&["  + Format(now(), "yyyy") + "]&[" +  Format(now(), "MM") + "]")}       SELECT {[Measures].[Asset Bookvalue balance]} ON 0, [MSN].[Asset].[Asset] on 1 from CMSX_DWH_OLAP  where [Book Value Start Date].[Year - Quarter - Month].[Month].&[2010]&[09]   next step is to change the two scripts in order to be used as a Calculated Member: CREATE MEMBER CURRENTCUBE.[Measures].[Todate Asset Bookvalue balance]  AS ([Measures].[Asset Bookvalue balance],{StrToMember("[Book Value Start Date].[Year - Quarter - Month].[Month].&["  + Format(now(), "yyyy") + "]&[" +  Format(now(), "MM") + "]")}),  FORMAT_STRING = "#,#.00;(#,#.00)",  VISIBLE = 1  ;       CREATE MEMBER CURRENTCUBE.[Measures].[Todate Asset Bookvalue balance2]  AS ([Measur

Data Type Convert problem?

1/2 is inputed by user, I hope to get the result 0.5, but both Method1 and Method2 get the result 0 How can I do? Thanks! BTW, I can't require user to input 1.0/2.0      Method1:     double my = 1/2;Method2:     double my = Convert.ToDouble(1/2);  

Date Range Problem

How would I go about returning the closest ReleaseDate to DateIn? The record I would like to return is (2010-07-18 00:00:00.000 2010-07-17 00:00:00.000) CREATE TABLE #test ( ID INT ,DateIn DATETIME ,ReleaseDate DATETIME ) INSERT INTO #test VALUES(1, '07/18/2010', '01/10/2010') INSERT INTO #test VALUES(2, '07/18/2010', '07/17/2010') SELECT * FROM #test WHERE CONVERT(CHAR(10), '07/17/2010', 101) <= CONVERT(CHAR(10), '07/18/2010', 101) AND CONVERT(CHAR(10), '07/18/2010', 101) <= CONVERT(CHAR(10), '01/10/2010', 101) DROP TABLE #test  

Unable to cast object of type problem

hi I'm having a problem in this code: Public Function GetChannelList() As List(Of channel) Implements IChannelService.GetChannelList         Dim db As ChannelDataContext = New ChannelDataContext         Dim channelMatch = From channelRow In db.channels _                           Join parentChild In db.ChannelParentChildListings _                           On channelRow.channel_id Equals parentChild.parent_id _                           Order By channelRow.title Ascending _                           Select channelRow.channel_id, channelRow.title, parentChild.child,   parentChild.child_id           Return channelMatch    <-------- Error throw Unable to cast object of type 'System.Data.Linq.DataQuery`1[VB$AnonymousType_1`4[S
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