Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Conversion of Date

  Asked By: Hondo    Date: Jul 14    Category: Asp.net    Views: 886
  

I have a date in the textBox say 20/02/2003 I am
trying to take it in a date Variabale
but it gives a err saying "Cast from string
"20/2/2003" to type 'Date' is not valid."
Then I tried type casting it with the help of CDate
still it Gives me and error going further
I tried DateValue function Hey I am Stuck with this
err of
"Cast from string "20/2/2003" to type 'Date' is not
valid."

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Patty Freeman     Answered On: Jul 14

I had the same problem, try to use a date  format dd/mm/YYYY to cast  to the date type.
"20/2/2003" -> "20/02/2003"

 
Answer #2    Answered By: Johnathan Nelson     Answered On: Jul 14

Just tell me How to retirve text from a text Box and
cast it as a date.All my Attempts are Failing

I tried this


TextBox1.Text = FormatDateTime(TextBox1.Text,
DateFormat.ShortDate)
Dim ds As date  =
FormatDateTime(CDate(TextBox1.Text),
DateFormat.GeneralDate)
Response.Write(DateAdd(DateInterval.Day, 1,
ds))

It gives the same err cant Convert string  to Date
Value.

 
Answer #3    Answered By: Horia Ahmed     Answered On: Jul 14

I'v tried this :
dim ds as date  = DateTime.Parse(textbox1.text)

this should give you back a date .....

 
Didn't find what you were looking for? Find more on Conversion of Date Or get search suggestion and latest updates.




Tagged: