-
August 18th, 2005, 02:42 AM
#1
How to get only date value in C#
How to get only date value in C#.
i am using system.datetime.now.date
it returns date with time.
Can any one give the solution
Regards,
sivakumar
-
August 18th, 2005, 03:03 AM
#2
Re: How to get only date value in C#
There is no date type in .Net, only DateTime.
To get only date you can do one of the following:
Code:
// Get current date and time
DateTime dt=DateTime.Now;
// Get year, month, and day
int year=dt.Year;
int month=dt.Month;
int day=dt.Day;
// Get datetime at midnight
DateTime date=dt.Date;
// Get long date string
string longDate=dt.ToLongDateString();
// Get short date string
string shortDate=dt.ToShortDateString();
// Get Ole Automation Date (number of days from midnight, 30 December 1899)
double oaDate=dt.ToOADate();
Last edited by klintan; August 18th, 2005 at 03:06 AM.
-
August 18th, 2005, 03:23 AM
#3
Re: How to get only date value in C#
using ultradatetimeeditor.value i am storing it in database and its value in database is 2005-08-18 00:00:00.000
and when i try to use
DateTime.Now.Date.ToShortDateString() its not retreive the record.
How come will i get the record by passing exact value as in database
Pls. give information.
Regards,
Sivakumar.kr
-
August 17th, 2006, 03:34 PM
#4
Re: How to get only date value in C#
try this way.
txtDueDate.MaskInput = "{LOC}mm/dd/yyyy";
-
August 18th, 2006, 01:44 AM
#5
Re: How to get only date value in C#
If your DB column type is "DATE" it should work.
If your column type is TIMESTAMP you may have to make your query a range. eg. WHERE col >= today AND col < tomorrow
Useful? Then click on (Rate This Post) at the top of this post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|