Click here to Skip to main content
15,844,498 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a function that have parameter for DateTime

AddNewRowToTable(....,DateTime ExpDate)


when i call that method like this below:

AddNewRowToTable(....,"2008/04/14")


it said it can't convert string to DateTime

help!
Posted
Updated 14-Jul-13 18:11pm
v2
Comments
Member 8437747 14-Jul-13 23:05pm    
It might be the type of DateTime you are or aren´t specifying(ie, DateTime.LongTime), can you post some of your code?

1 solution

Hi, try to use this:

C#
string date = "2008/04/14";
DateTime dt = Convert.ToDateTime(date);

AddNewRow(....,dt)


Or this,

C#
string Date = "2008/04/14";
DateTime myDate = DateTime.Parse(Date);
 
AddNewRow(....,myDate)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900