How to get Date Value

Hi...

I have this code, which will returned this: 12/30/2008 12:00:00AM.

DateTime dtNow;
dtNow = DateTime.Today;

 

  1. What I wanted is to display the Date only.
  2. The date format not following the system date format of yyyy-MM-dd.

Any idea?

0
ryanlcs
12/30/2008 7:03:28 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

8 Replies
300 Views

Similar Articles

[PageSpeed] 7

String str = dtNow.ToShortDateString();


MAKMark as Answer if this reply helps you
MVP ASP/ASP.Net
MVP ASP/ASP.Net
ASP.Net Hosting : Host DepotMy Site : ASPSnippets
0
mudassarkhan
12/30/2008 7:46:14 AM

Try out this line

DateTime.Today.ToString("yyyy-MM-dd");

 


Please remember to click “Mark as Answer” on the post that helps you.

This can be beneficial to other community members reading the thread.

0
Pratik
12/30/2008 7:46:58 AM

mudassarkhan:

String str = dtNow.ToShortDateString();

 I am half way there, just that the format remain as mm-dd-yyyy. I am expecting it will follow to current system formar of yyyy-mm-dd, or do I need customize formating?

0
ryanlcs
12/30/2008 7:52:13 AM

Are You tried my Code line as ?

DateTime.Today.ToString("yyyy-MM-dd");

it will give you date as 2008-12-30 


Please remember to click “Mark as Answer” on the post that helps you.

This can be beneficial to other community members reading the thread.

0
Pratik
12/30/2008 7:58:52 AM

Hi,

         The Answer is

                          string date = DateTime.Today.ToShortDateString();

                 This may help you,

Thank You,

Manoj Chavan

-----------------------------------

Web Application Developer

 


Thank You
Manoj Chavan
-------------------------------------------
Web Application Developer(C#.NET, ASP.NET, C++.NET)
My Blog
Always think high, Always Dream High.
If this post helps you then plz Mark It as Answer
0
manojlev
12/30/2008 8:02:02 AM

String str = dtNow.Year + "/" + dtNow.Month + "/" dtNow.Day


MAKMark as Answer if this reply helps you
MVP ASP/ASP.Net
MVP ASP/ASP.Net
ASP.Net Hosting : Host DepotMy Site : ASPSnippets
0
mudassarkhan
12/30/2008 8:02:54 AM

 Doubles slashes in C# 

String str = dtNow.Year + "//" + dtNow.Month + "//" dtNow.Day


MAKMark as Answer if this reply helps you
MVP ASP/ASP.Net
MVP ASP/ASP.Net
ASP.Net Hosting : Host DepotMy Site : ASPSnippets
0
mudassarkhan
12/30/2008 8:05:07 AM

Pratik N:

Are You tried my Code line as ?

DateTime.Today.ToString("yyyy-MM-dd");

it will give you date as 2008-12-30 


Please remember to click “Mark as Answer” on the post that helps you.

This can be beneficial to other community members reading the thread.

 

It works...but I suppose I need not require to specify "YYYY-MM-DD" in the conversion, at least classic ASP does not require this.

Anyway, this is another work around method. Thanks.

0
ryanlcs
12/30/2008 8:08:51 AM
Reply:

Similar Artilces:

POST GET GET GET GET... WTH?
Hi, I'm at a loss to explain this... I have an ASPX page that I can't always navigate to. When I developed the app (it's Starter Kit Portal-based), I did it on my LAN and have had no trouble accessing the page. However, upon deployment, I see the following behavior: 1. POST request goes out looking for MyForm.aspx 2. GET request for MyForm.aspx 3. GET request for MyForm.aspx 4. ... X. GET request Sometimes, the page finally loads. Other times, it just ends up blank. Many times, it doesn't load at ALL the first POST - I just get a "The pa...

problem with get value from textbox after get it value in load page
hi every one  i have problem with my web site when i get textbox value in load page   and Changed textbox the page do not take last value .   it take value in load page   this is code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)   TextBox1.Text = "aa" End SubProtected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) MsgBox(TextBox1.Text) End Sub   when i press button message write "aa" while i changed the textbox   please if enyone knowen help me &nbs...

trying to get started and i am getting this error
when i go to http://www.porkchopsplayground.com, i get: DotNetNuke Upgrade Error The Assembly Version ( [ASSEMBLYVERSION] ) does not match the Database Version ( [DATABASEVERSION] ) ERROR: Could not connect to database. Could not find file 'd:\hosting\nmoran26\Providers\DataProviders\AccessDataProvider\DotNetNuke.mdb'. Any suggestions will be appreciated. Thanks, Nicole Do you have a username and password set on your database? Make sure you follow the steps mentionned in the Readme.txt located in the documentation folder. In any case make sure your credentials for yo...

Query for substring to get some particular value in a string (Get querystring value by sql )
I have a column name URL in Table1 with data like  <a href="/Folder1/view_media_news.cfm?news_media_i=1">August 2002 Factsheet</a>            <a href="/Folder1/view_media_news.cfm?news_media_i=149">March 2002 Newsletter </a>  i need to grab the news_media_i value by sql query  Please any one can help me to get that particular value from string using substring or any other suggestion Thank you in advance SurendraIf this helps mark it as answer surendra_kla:i nee...

Getting Start With .net
hi i'm intersted to learn asp.net (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 microsoft.net 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 delphi.net) 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...

Getting line number to show during editing, getting values to show during debug, getting MSDN help to know that I have it installed
G'day, Sorry I feel so dumb but these issues just push me over the edge. I've recently had to re-install VS and now none of these features that I once had now don't work.  I obviously have to tweak something but what?  It doesn't seem too obvious (I hope!)Help please!Thanks,Geoff Line numbers - that can found under Tools > Options > Text Editor > (Language) > (somewhere there, there is is a check box for line numbers) When you are in the debug mode of the IDE, go into the Debug > Windows > (whatever windows you need - locals/autos are what you're l...

Get the Hightlight values of a ListBox but, Hightlighting two or three or four items and it get the values of each one
How do I get the Hightlight values of a ListBox but, Hightlighting two or three or four items and it get the values of each one? Thanks The following statements obtain the text of all the selected items in a ListBox that allows the user to select more than one item. The MessageBox function displays each item as it is found. You could include other processing that created an array or list of the selected values: integer li_ItemTotal, li_ItemCount // Get the number of items in the ListBox. li_ItemTotal = lb_contact.TotalItems( ) // Loop through all...

How do I get get values of controls inside datalist?
How do I get values of controls inside datalist?   For example, if I have a label inside header template or item template or footer template? Is there anyway to change property of label or any other controls inside those template as well? I would really appreciate if anybody can just post a sample code or a helpful link about datalist? Would really like to know more about the events fired for datalist, itembound, itemcreating etc?   hey there,I used this page to work out how to use datalists http://www.eggheadcafe.com/tutorials/aspnet/d89d1d96-03f1-4784-bbb2-a3db1af...

getting started in VS2005 C# which book should I get
Hello, I am getting started with VS2005, I have use VS2003 but not very much -(I did 4 small applications in it),  I am wondering which book you would recommend to learn the new features of VS2005, while learning more of C# programing in general There some links to good books in this thread i posted : http://forums.asp.net/thread/1489422.aspx Also these two make good reference material  Professional Visual Studio 2005 (Programmer to Programmer)   Microsoft Visual Studio 2005 Unleashed  So far I recommend Wrox's C# 2005  Read the beginning chap...

Getting error in Net::SFTP with get function
------=_Part_7028_3315294.1193837808284 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi All, I have the following code as part of my program; print "---=========> $file, $localFile\n"; $sftp -> get( $file, $localFile ) || warn("errrrr0rrrrr _---> $!".$sftp->status."\n");^M Even though it has downloaded the file properly, it is giving the following message: ---=========> /trading/tiscrdenhlist10310000.txt.old, /export/home/crdadm/rajeev/tiscrdenhlist103...

How to get DataTable object from DB and get Values from it
Here the code I use ...  SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);        SqlDataAdapter Adptr = new SqlDataAdapter("Select * from AccountType ", con );DataTable mytbl = new DataTable("tbl"); Adptr.Fill(mytbl)       if (mytbl.Rows[0][1].ToString()) == "Classic")  /// Here I gey a message : There is no row 0 in table .... I checked DataTable with Response.Write( mytbl.Rows.Count )  it gives me 0 ... What can be the pro...

get rid of that ridiculous getting started bookmark
Name: DOCTOR Product: Firefox Summary: get rid of that ridiculous getting started bookmark Comments: Browser Details: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.22 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

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 ...

Web resources about - How to get Date Value - asp.net.getting-started

Apple, Samsung and Sony Linked to Child Labor Cobalt Mining Claims
A new report by Amnesty International claims that Apple, Samsung and Sony are consistently failing to perform the basic checks which are required ...

Academy president 'heartbroken' over #OscarsSoWhite, vows more action
LOS ANGELES — Cheryl Boone Isaacs, speaking on behalf of the Academy of Motion Picture Arts and Sciences of which she is president, issued a ...

R.I.P, Glenn Frey
In honor of Glenn Frey, classic rock radio stations will be playing The Eagles all day for the past 25 years. — ⚡David Angelo⚡ (@MrDavidAngelo) ...

Family members and congressmen reunited with freed Americans
NDTV Family members and congressmen reunited with freed Americans Sacramento Bee Jason Rezaian, the Washington Post reporter who was freed ...

China's growth hits quarter-century low, raising hopes of more stimulus
By Pete Sweeney and Samuel Shen SHANGHAI (Reuters) - China's economy grew at its weakest pace in a quarter of a century last year, raising hopes ...

9-year-old actor Jacob Tremblay had the cutest awards ceremony in history
9-year-old Jacob Tremblay took home the Critics' Choice Award for Best Young Performer for his work in Room on Sunday Night, and more importantly, ...

Netflix renews 'Jessica Jones,' reveals premiere dates
WGNO Netflix renews 'Jessica Jones,' reveals premiere dates WGNO Netflix also announced premiere dates Sunday for these new and returning ...

WhatsApp Does Away With $0.99 Per Year Fee, Is Now Free to Use
That nominal $0.99 per year fee for WhatsApp is coming to an end, with a blog post from WhatsApp today announcing that over the next month, they ...

'American Pie' singer Don McLean charged in Camden with domestic violence
Press Herald 'American Pie' singer Don McLean charged in Camden with domestic violence Press Herald McLean, 70, was arrested at his home early ...

Flint's water crisis vexes area bars and restaurants
The Detroit News Flint's water crisis vexes area bars and restaurants The Detroit News Establishments say problem has prompted them to serve ...

Resources last updated: 1/19/2016 11:34:44 AM