Solved

convert date with asp.net c# 2.0

Posted on 2007-03-19
3
381 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

735 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