Minima
Minima

Reputation: 133

Set DateTimePicker Value from a retrieved Time in SQL Server

I'm having a hard time in assigning values that came from my database,

Value to be retrieved :

AppointmentTime
Value = 11:00:00
Data Type = time(0)

I use VS 2010 to assign that value from SQL Server 2008 with a DateTimePicker..

DateTimePicker1
Format = HH:mm
MinDate = 1/1/1770

DateTimePicker1.Value = Appointment Time

It gives me an error of 'Value of 1/1/0001 11:00:00AM is not valid for Value. Value should be between MinDate and MaxDate..

I wonder why SQL Server 2008 gives a value of Date, in my Time(0) Column?

Upvotes: 0

Views: 793

Answers (1)

Iswanto San
Iswanto San

Reputation: 18569

I try this query

declare @x time(0);
set @x = getdate();
print cast(@x as datetime);

It will be give you the time with the date 01/01/1900.

So, try to cast Appointment Time to DateTime before set the DateTimePicker1 value.

Upvotes: 1

Related Questions