Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Cannot implicitly convert type 'string' to 'System.DateTime'

Avatar of kwh3856
kwh3856Flag for United States of America asked on
.NET ProgrammingVisual Basic.NET
4 Comments1 Solution1069 ViewsLast Modified:
I am trying to initialize a data variable.  I initializing the variable to 0's but when I saved it to the database the database gave an error message of

SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

Now, I am trying to set the variable to this date and time for the initilization.  When I try to set the variable it gives me the Cannot Implicitly convert type 'string' to SystemDateTime.

Can someone show me the correct syntax to accomplish this task?

Here is my code:
DateTime dt = new DateTime();
 
                    if (dt.CompareTo(new DateTime()) == 0)
                    {
                        // Date is set to min, 1/1/0001 12:00:00 AM
                        // SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
 
                        dt = "1/1/1753 12:00:00 AM";
 
                    }
                    else
                    {
                        MyGlobalVars.dob = Convert.ToDateTime(userrec.patuser.dob);
                    }
ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHewsFlag of Canada image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers