469,645 Members | 1,702 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

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 2696
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

Post your reply

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

Similar topics

2 posts views Thread by Abhishek Srivastava | last post: by
2 posts views Thread by megala | last post: by
reply views Thread by Raju5725 | last post: by
1 post views Thread by l7alabeh | last post: by
6 posts views Thread by nady | last post: by
satiss7pwr
5 posts views Thread by satiss7pwr | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.