Solved

DateTime.Parse() problem

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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