Solved

Datetime in c#.net

Posted on 2006-06-21
3
3,142 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
[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
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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…

736 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