Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Datetime in c#.net

Posted on 2006-06-21
3
Medium Priority
?
3,150 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 2000 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 to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

971 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