Solved

DateTime.Parse() problem

Posted on 2004-09-21
4
436 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

738 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