Solved

DateTime.Parse() problem

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

23 Experts available now in Live!

Get 1:1 Help Now