Solved

Datetime in c#.net

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
About delegates in c sharp 3 49
C# HTTP GET method sample code 3 59
How can i use linq for parsing string datetime to real datetime? 16 45
HttpPostedFile 1 26
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

822 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