473,770 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2904
aspdotnetuser
22 New Member
Have you tried CDate( string )
Dec 8 '10 #2
Frinavale
9,735 Recognized Expert Moderator Expert
You could also try using one of the DateTime.TryPar se() methods.

-Frinny
Dec 9 '10 #3
object13
1 New Member
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
10883
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
14490
by: megala | last post by:
Hi How to convert a string "11022005" to a specific date format-02/11/2005
0
2762
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 & "-" & Str1 & " " & Str3)....i want to put them all together and i want to get a datetime. I tried with Cdate(BEGIN_DATE_TIME) but it is throwing an exception as An unhandled exception of type 'System.InvalidCastException' occurred in...
1
1597
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
83888
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 'Thank you very much
3
2788
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 select * from table_name where to_date(%date%, 'MM/DD/YYYY) > (SYSDATE - 7); this gives an error saying the month is not valid when the month in %date% is single digit. Please help
6
5534
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 date. please help
5
3504
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
3651
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
22688
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 to a date or a pre-existing function?
0
10260
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9910
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.