473,408 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

how to convert string from database into date in asp.net?

How do you convert string from database into date in asp.net?
Expand|Select|Wrap|Line Numbers
  1. Dim output = (From tlb In  obj.SelectRecordAll_SalesInquiryRegister _
  2.                      Join tlb1 In LatestPOs On tlb.SIR_OfferNo Equals tlb1.OfferNo _
  3.                      And tlb.SIR_AlterationNo Equals tlb1.PORevNo _
  4.                      Order By tlb.SIR_Flag _
  5.                      Select _
  6.                            SIRID = tlb.Marketing_SalesInquiryRegister_ID, _
  7.                           poaltno = tlb.SIR_AlterationNo, _
  8.                           OfferNo = tlb.SIR_OfferNo, _
  9.                           PONo = tlb.SIR_Flag, _
  10.                            poStatus = GetPOStatus(tlb.SIR_OfferNo, tlb.SIR_AlterationNo), _
  11.                            Consignee = tlb.Marketing_Inquiry_Detail.Company_Master.Company_Name, _
  12.                            ProductName = tlb.Marketing_Inquiry_Detail.QC_Product_Master.Product_Name, _
  13.                            CreditPeriods = tlb.SIR_CreditPeriodDays, _
  14.                            POAmount = Decimal.Round(tlb.Marketing_OfferPackingQuantity_Detail.Offer_Quantity * tlb.Marketing_OfferPrice_Detail.Offer_PricePerUnit, 2, MidpointRounding.AwayFromZero), _
  15.                            Details1 = (From t In obj.SelectRecordAll_OfferDeliverySchedule _
  16.                                       Where t.DeliverySchedule_SIRID = tlb.Marketing_SalesInquiryRegister_ID _
  17.                                       Select SheduleDate = t.DeliverySchedule_Date, _
  18.                                               id = t.Marketing_OfferDeliverySchedule_Details_ID), _
  19.                            Details4 = (From t In obj.SelectRecordAll_OfferDeliverySchedule _
  20.                                        Where t.DeliverySchedule_SIRID = tlb.Marketing_SalesInquiryRegister_ID _
  21.                                        Select SheduleQty = t.DeliverySchedule_Quantity, _
  22.                                        id = t.Marketing_OfferDeliverySchedule_Details_ID), _
  23.                            Company = tlb.Marketing_Offer_Detail.Offer_CompanyID).ToList
  24.  
  25.  
  26. lsvReport.DataSource = output
  27. lsvReport.DataBind()
  28. dim i as integer = 0
  29. for each item in output
  30. dim adddt =DateAdd("d", CType(output(i).CreditPeriods, Integer), DateTime.Parse(output(i).Details1(i).SheduleDate))
  31. i=i+1
  32. next
The error that I am getting is The string was not recognized as a valid DateTime

How to I solve this error?


how to convert string into date
Nov 26 '10 #1
3 2879
Have you tried CDate( string )
Dec 8 '10 #2
Frinavale
9,735 Expert Mod 8TB
You could also try using one of the DateTime.TryParse() methods.

-Frinny
Dec 9 '10 #3
Try the DateTime.Parse method as mentioned here:
http://siglingsoftware.blogspot.com/...structure.html
Feb 10 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Abhishek Srivastava | last post by:
Hello All, I wrote the following program. using System; using System.Globalization; public class ShortDateTest { public static void Main(string args)
2
by: megala | last post by:
Hi How to convert a string "11022005" to a specific date format-02/11/2005
0
by: Raju5725 | last post by:
Hi... I am having string variable "BEGIN_DATE_TIME", in which there are three other variables each gives me ....month, date in on string and year in one string and time in another strings(Str2 &...
1
by: l7alabeh | last post by:
Hey, I have a String and I want to convert it to a date in Visual Basic (ASP.NET 2.0) How can I do so??
4
by: Aobaidat79 | last post by:
Dear Freinds I have string contains the date like "21Jun2000" What I want to do is to convert that string into date in the following format 21 Jun 2000 Plesae help me as soon as possible...
3
by: upriyaa | last post by:
Hi My requirement is to compare a date in string format with the Sysdate. The problem is the date string does not contain a zero before the single digit date and month. Here is my query ...
6
by: nady | last post by:
Hi, I have a database in mysql i have column which is text and i need to convert it to date for query purposes. the format for the string in the column is dd/mm/yyyy i need to convert this to...
5
satiss7pwr
by: satiss7pwr | last post by:
I have a string date like this: "3/28/2008 12:05:45 pm" i want to convert it into date and display the out put any one can help me plssssssssss
4
by: Shivareddy | last post by:
i have date in string in this format eg. 1/20/21011 i need to convert it into the date object
5
dsatino
by: dsatino | last post by:
I'm getting a tab delimited file that I need to import into an access DB. The date field comes over as an 8 character string in the yyyymmdd format. Does anyone know an easy way to convert this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.