Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Datetime in c#.net

Posted on 2006-06-21
3
Medium Priority
?
3,148 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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

670 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