Solved

DateTime.Parse() problem

Posted on 2004-09-21
4
437 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

728 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