Solved

DateTime.Parse() problem

Posted on 2004-09-21
4
424 Views
Last Modified: 2012-08-14
Using
DateTime.Parse("15:00")
will pass Today's date + 15:00 into DB and become

21/09/2004 03:00:00 PM

=================

If I only want to pass the TIME (15:00) into db and become

03:00:00 PM

in the DB...

how can I parse?

Thanks.
0
Comment
Question by:p931226
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
mmarinov earned 30 total points
ID: 12120419
Hi,
you can get is as string with this
DateTime.Parse("15:00").ToString("t")
or
DateTime.Parse("15:00").ToShortTimeString()



Regards,
B..M
0
 

Author Comment

by:p931226
ID: 12121458
My code:
lst.setSentTime(DateTime.Parse(st.Text).ToLongTimeString());      

But has the following errors:
=========================
error CS1502:  lst.setSentTime(System.DateTime)' has some invalid arguments
error CS1503: Argument '1': cannot convert from 'string' to 'System.DateTime'


why?
Thanks.
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12121512
that is because you design the field of the database to be datetime and this contains date and time
if you want to log just the time - redesign it as string

B..M
0
 

Author Comment

by:p931226
ID: 12122737
ic, thanks B..M.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now