Solved

convert date with asp.net c# 2.0

Posted on 2007-03-19
3
377 Views
Last Modified: 2008-02-01
I'm getting a date value of: 1/30/2007
Need to convert it to: 2007-01-30
when the submit button is clicked I get a start date:
GMDatePicker1.Date.ToShortDateString()  //comes back as 1/30/2007

so do I need to call a function that will return it as 2007-01-30?

how do I write it?
0
Comment
Question by:fwsteal
  • 2
3 Comments
 
LVL 37

Expert Comment

by:samtran0331
ID: 18749692
try this:
GMDatePicker1.Date.ToShortDateString.Format("yyyy-mm-dd")
0
 

Author Comment

by:fwsteal
ID: 18750167
string startdt = GMDatePicker1.Date.ToShortDateString.Format("yyyy-mm-dd") + " " + txtStartDate.Text;

Error:
'System.DateTime.ToShortDateString()' is a 'method', which is not valid in the given context
0
 
LVL 37

Accepted Solution

by:
samtran0331 earned 500 total points
ID: 18750444
try just "tostring" instead of "toshortdatestring"...


        GMDatePicker1.Date.ToString("yyyy-MM-dd")
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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