Solved

convert date with asp.net c# 2.0

Posted on 2007-03-19
3
383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project

734 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