Solved

Datetime in c#.net

Posted on 2006-06-21
3
3,136 Views
Last Modified: 2008-04-23
Hello experts,

I am doing an insert sattement, for which one of the values is a date.

I need to get the current date/time, place the date and time in two seperate variables, and insert the date and then the time in two seprate fields ion the database. (Seperate date and time required for IBM DB2 database - no datetime data type.)

how do I do that....

I have gottent this far;-

DateTime DATETIMESTAMP = DateTime.Now;

and then...

thanks
0
Comment
Question by:claracruz
  • 2
3 Comments
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16950791
try
for date
System.DateTime a=DateTime.Now.Date;
0
 
LVL 7

Accepted Solution

by:
pradeepsudharsan earned 500 total points
ID: 16950807

hi,

try
like this
for date
--------------
System.DateTime a=DateTime.Now.Date;

for time
--------
string b=DateTime.Now.TimeOfDay.ToString();

regards
Pradeep
0
 
LVL 5

Expert Comment

by:rameedev
ID: 16984560
DateTime Dt = DateTime.Now;

                  string sDateOnly = Dt.GetDateTimeFormats().GetValue(0).ToString();
                  string sTimeOnly = Dt.GetDateTimeFormats().GetValue(104).ToString();
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

17 Experts available now in Live!

Get 1:1 Help Now