Accessing various parts of the Date or DateTime

How do I access the parts of the Date or DateTime object.

I like to get
1. the day of the month formatted in two digits (01, or 12)
2. month of the year formatted in two digits (01, or 12)
3. and year (01 or 05)
1/19/2005 9:00:58 PM 91979 articles. 4 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 0
Get it on Google Play
Get it on Apple App Store

Hi jty202,

Try out the following. Let us know if this is not what you had in mind.


There's plenty of more information on Date Time Format Specifiers available from MSDN. See
Hope this helps.
Geoffrey McGill - Product Manager
Basic Date Picker - A Quicker Picker(TM) - ASP.NET Calendar, Date and Time Web Controls
1/19/2005 9:38:48 PM
Does the Date object have the same functions? not DateTime? I am asking for Date object

1/19/2005 10:45:43 PM
I believe Date and DateTime are exactly the same. Date is just an alias for DateTime. I'm more of a C# guy, so I may to totally out to lunch on this one. 

It's the same thing with String and string in C#. They both do the same thing.
Geoffrey McGill - Product Manager
Basic Date Picker - A Quicker Picker(TM) - ASP.NET Calendar, Date and Time Web Controls
1/19/2005 11:07:09 PM
Can do this


to get this
1/19/2005 11:30:51 PM
Yes, it is just an alias.
1/20/2005 12:02:27 AM

Similar Artilces:

Parse DateTime into Date or select DateTime as Date from Access
I am getting DateTime values out of an Access Database and I want to only use the Date part of this field. I have tried to cast the returned value to a DateTime value and then format the DateTime to only show the Date part in the toString() fcn. <asp:Label runat="server" Text='<%# getDate(DataBinder.Eval(Container, "DataItem.ACTIVE_FROM"))%>'> But I can't cast the object to a DateTime object. I have also tried using DateTime.Parse() but this gives an error saying that the format is not correct.         {       ...

How do I get the date part from datetime variable ?
How do I get the date part from datetime variable ? e.g declare @start_time datetime select @start_time = "10/31/2003" This puts date and current System time into the variable. I use this for some comparison on datetime field on database. But when I do the comparison, I want to do the comparison without time part on database field and my variable. How do I do that ? Thanks Check out the datepart function. In article <3fd10c0f$1@forums-1-dub>, <phari> says... > How do I get the date part from datetime variable ? > > e.g > declare...

get only date from a date with a datetime format
i have a problem with dates when it comes to searchingbasically, SQL searches for a date including the seconds,but i only need to date so that in any given time, it will yield a's a part of my code-behind code: reqNo = RequisitionsLogic.GetReqNoByDate(currentDate, requestorCode)and here's the SQL statement created in a TableAdapter:SELECT RequisitionNoFROM RequisitionsWHERE (RequisitionDate = @RequisitionDate) AND (RequestorCode = @RequestorCode) take a look with this, don't just accept influenceshttp://thedailyarr.tk

Get date portion from DateTime (with DateTime property)
    private string _Date;    public string Date    {        get { return _Date; }        set { _Date = value; }    } objDados.Date = Convert.ToDateTime(drResult["APP_DATE"]).Date.ToString("dd/MM/yyyy"); If I replace _Date from string to DateTime, how can I get only date portion from DateTime? ThanksBest regards,Ivan Andrade Hi  you could always copy it. But I'd put the Date property to be of DateTime type. Something like:  &...

How to remove the date part of a Date/Time value in MS Access
I am inserting a time value into a MS Access Date/Time field and notice that MS Access does not display the date portion of the value but when I look at the same data in my programming using a TADOTable component I am seeing the date of 12/30/1899 in conjunction with my time value. I read that Access is handling this within MS Access so that when a 0.sometime value is inserted it does not display the date. How do I handle this within my Delphi program so that I can display the time only in a Date/Time type field? Jeff Howard wrote: > I am inserting a time value into a MS Access Date/T...

Getting Start With .net
hi i'm intersted to learn (vb or delphi) . i programming with delphi6 but i'd like to tp know something about programming in internet specially with .net . i hear about with delphi 7 that i can programming with delphi in .net .... is it right ? what 's our opinian about it ? and better to learn Vb.Net or continu with delphi(or thanks. Ali Darabian I think there is some support for Delphi in .Net. However, you will find much more support from the user community if you choose a more popular language such as VB.Net or C#. Since your al...

how to get start with .NET
the net help people installed  to my desktop 1-microsoft visual studio .NET enterprise developer 2003 2-microsoft .NET framework 1.1 what else do i need ...???  and how can i try with some simple code in VS.Net and run it to see wat happen...????? please help If you want to develope web applications, then you'll also need IIS on your PC.  That'll require XP-Professional or Windows 2000/2003, but XP-Home edition won't allow IIS installation. As for how to get started, you can search the web for some tutorials or buy a good book on VS.  The topic is way too vast to...

How to get week start date, End date for a given week nunber,year?
I want  a javascript function to to get the starting date and end date of a week when I have given the week number (1 to 5), Month number (1 to 12), valid year as parameter. How to do that?Manivannan  You can visited dont have example.Hope it's help you. try this example function GetWeekStartEndDate(){    var week = 5;    var month = 4;    var year = 2008;        var PositiveOneDay = new Date(new Date('1/2/2000') - new Date('1/1/2000'));   &...

Where to start and how did you get started?
Hi, I have had a feeling for a long time to jump into the adds market for some time due to my low income (shooting for the stars) and I don't have anything better to do these days. But I find it really difficult not to give up due to lack of guides (what I can find atleast) and all the hard words which only makes me confused. But I won't give up. Never. Not sure if this is the right place to post this, but I deffinitly would be really greatfull for help getting started. How did you get started? +If there are any teacher that wanna show me the ropes private, I can give payment with ...

Can not get Pickup Directory... .net can't access metabase maybe??? Need to get working ASAP
I am using 2.0 to try to send an email to the IisPickup directorySystem.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(, "", "Testing " + DateTime.Now.ToString(), "Testing the Mail Drop Folder");System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("");client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.PickupDirectoryFromIis; client.Send(message);Example Site : (hit the button)This code worked on our old deployment server but not on our new server.  I s...

Getting parts of DateTime field
Hi everyone, I want to get year, month, day and time parts of a DateTime field in sql, Can help me? There are many datetime functions you can use. For example: You can use Year(dtColumn), Month(dtColumn) to get year and month returned in integer format. You can also  use DATEPART function to get the part you want, for example: Datepart(yyyy,dtColumn) to get year. Here is the full list from MSDN library:    Limno...

Getting started .net website
Hi folks,Does anyone here know of a good website to just sit back and read for learning .net? Thanks in advance.Baldeep Right here... Click the Get Started and Learn sections here. Quite a few out there - - this one, has a lot of good videos -  also, but then, I might be a little prejudiced David WierMCP/ - where to look first!Please Vote for ASPNet101 - 'Best Community Resource'!Control Grouper - easily control properties for multiple controls with one control!Calendar Express - The Best HTML Calendar Generator on the web!(P...

Get Date portion from Datetime
Hi all How to get just the date portion from a datetime field from sql server? thanks a lotBest regards,Ivan Andrade CONVERT(varchar,yourDateColumn,101)   Check out CONVERT function in BOL for more options.***********************Dinakar NethiLife is short. Enjoy it.*********************** Hi I'm getting a System.IndexOutOfRangeException error in resultset while(result.Read())    {    this.escritorios.codEscritorio = (int) result["Cod_escritorio"];    this.filiais.codFilial = (int) result["Cod_filial"];   &nb...

Getting Started with .net and a few questions
Hello I've done some asp and php programming along with various other languages in the past and slowing getting my head around .net.I have a small project of creating a Holiday Booking system on our Intranet and just trying to get the first part to work properly will hopefully get me sorted for the whole project. The Intranet is running on .net 2 and I prefer to use the VB code rather than C#. This is connecting to an SQL server.My initial page that I am trying to create is just for an admin user to view which dates in a table have been specified as Bank Holidays and be able to add ...

Web resources about - Accessing various parts of the Date or DateTime -

Highest Percentage Of Opera Mini Users Accessing Facebook? Macau
If you were asked to guess which country had the highest percentage of users of Opera mobile Web browser Opera Mini users accessing Facebook ...

International Users Accessing Facebook Places Through US VPN Accounts
By using a virtual private network (VPN) hosted in the United States, Facebook users from around the world are accessing Facebook Places. The ...

What are some alternatives to Yodlee for accessing bank information?
Clay Loveless , Founder, Jexy. Co-founder, Mashery. Founder, Jexy. Co-founder, Mashery.

Cloud Console - Accessing files in cloud storage for iPad on the iTunes App Store
Get Cloud Console - Accessing files in cloud storage on the App Store. See screenshots and ratings, and read customer reviews.

Meryl Streep On Accessing The Characters Within - YouTube
Meryl Streep talks about the importance of an actors work representing their ability. CONNECT WITH AFI: ...

Student pleads guilty to accessing records about Frances Abbott design scholarship
The Sydney student who leaked information about a fashion school scholarship controversially awarded to the daughter of the Prime Minister has ...

Accessing a headline opinion
Accessing a headline opinion

Sharp increase in authorities accessing private data
Australian law enforcement and government agencies have sharply increased their access without warrant to vast quantities of private telephone ...

Former librarian charged with accessing student records of Frances Abbott
A former part-time librarian at a Sydney design school has been charged after she allegedly accessed student records of Prime Minister Tony Abbott's ...

Frances Abbott scholarship: Sydney woman pleads guilty to accessing Whitehouse Institute records on PM's ...
A Sydney woman who leaked the student records of Tony Abbott's daughter pleads guilty. A Sydney woman who leaked the student records of Prime ...

Resources last updated: 12/9/2015 9:39:04 PM