ANINDYA
asked on
DatetimePicker Problem C#
Experts,
I have qestion that is when I am selecting any date from the datetimepicker as in this form (return date) then it is taking the date and also the time. (Please see the image attached)
I am doing in this manner
DateTime DateofReturn;
DateofReturn = dateTimePicker_ReturningDa te.Value;
And the query I am using for Save option is
string query = "insert into Table_Borrow(MemberID,Film _ID,Nameof Item,Dateo fReturn,St atus) values(@parameter1,@parame ter2,@para meter3,@pa rameter4,' " + b.ToString() + "')";
May I know what I have to do so that only the date as selected from the datetimepicker should get saved not time (that is 7A.M. should not get saved)
Thanking you,
Anindya
error.jpg
I have qestion that is when I am selecting any date from the datetimepicker as in this form (return date) then it is taking the date and also the time. (Please see the image attached)
I am doing in this manner
DateTime DateofReturn;
DateofReturn = dateTimePicker_ReturningDa
And the query I am using for Save option is
string query = "insert into Table_Borrow(MemberID,Film
May I know what I have to do so that only the date as selected from the datetimepicker should get saved not time (that is 7A.M. should not get saved)
Thanking you,
Anindya
error.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry,
Same answer as: mas_oz2003
Same answer as: mas_oz2003
ASKER
ASKER
Try this.
DateofReturn = dateTimePicker_ReturningDa te.Value.D ate
DateofReturn = dateTimePicker_ReturningDa
ASKER
Expert saravanansofts
Itried the same
but the problem is it is taking date followed by 00:00:00
why this is coming ?
How to ommit it?
Thanking you
anindya
Itried the same
but the problem is it is taking date followed by 00:00:00
why this is coming ?
How to ommit it?
Thanking you
anindya
What version of Sql are you using ?
only in 2008 can you have a date only field, prior to this all date fields in sql are date and time .... which means if you put a date without a time sql (and c#) will put a time of 00:00:00in. This is not avoidable.
if you are using sql 2008 then change your data time from datetime/ smalldatetime to date
only in 2008 can you have a date only field, prior to this all date fields in sql are date and time .... which means if you put a date without a time sql (and c#) will put a time of 00:00:00in. This is not avoidable.
if you are using sql 2008 then change your data time from datetime/ smalldatetime to date
ASKER
experts
I am using sql server 2005
I am using sql server 2005
ASKER
Expert zadeveloper:
I am using sql server 2005.
Thanking you
Anindya
I am using sql server 2005.
Thanking you
Anindya
ASKER
The datatype is DateTime which I am using here for the returndate attribute.
Thanking you
Thanking you
try this one
I Think you should use varchar(12) instead of datetime. that will solve your Problem. while saving just save your string as '2010/07/09'.
Best Regards
Waqar Hussain Laghari
I Think you should use varchar(12) instead of datetime. that will solve your Problem. while saving just save your string as '2010/07/09'.
Best Regards
Waqar Hussain Laghari
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Master zadeveloper
I have seen that your 1st reply was same as that of Expert mas_OZ2003.
So I am sorry that I had not addressed you .
Sir if you see the reply which I had given after you and mas_OZ2003 suggested me the solution.
If you kindly see the two images attached at that time then I think you will get the clear picture of what is happening .
Sir the problem is I am saving the value of the date and the date is getting saved with date correctly but after using the
dateTimePicker_ReturningDa te.Value.D ate
I am getting date as well the 00:00:00 also .
Please see the images attached for clarification.
I want in the table only the date should get saved not date and 00:00:00
Thanking you
Anindya
I have seen that your 1st reply was same as that of Expert mas_OZ2003.
So I am sorry that I had not addressed you .
Sir if you see the reply which I had given after you and mas_OZ2003 suggested me the solution.
If you kindly see the two images attached at that time then I think you will get the clear picture of what is happening .
Sir the problem is I am saving the value of the date and the date is getting saved with date correctly but after using the
dateTimePicker_ReturningDa
I am getting date as well the 00:00:00 also .
Please see the images attached for clarification.
I want in the table only the date should get saved not date and 00:00:00
Thanking you
Anindya
ASKER
Expert Waqar Hussain Laghari
I am not going to change the datatype as it may cause some problem for me in other sections .
Thanking you
Anindya
I am not going to change the datatype as it may cause some problem for me in other sections .
Thanking you
Anindya
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Experts
thanks for answering me .
Although my problem is not solved but I think it is better to keep with the previous state.
Thanking you,
Anindya Chatterjee
Bangalore
thanks for answering me .
Although my problem is not solved but I think it is better to keep with the previous state.
Thanking you,
Anindya Chatterjee
Bangalore
Hi! Anindya
It will be suitable for you IF you will take date as varchar(8) etc. as suggested by waqarlaghar It will help you to proceed easily in the future. I know tables have some dependencies. But its better to remove a problem rather than to use a local way. ;)
So, if possible try an easier approach.
It will be suitable for you IF you will take date as varchar(8) etc. as suggested by waqarlaghar It will help you to proceed easily in the future. I know tables have some dependencies. But its better to remove a problem rather than to use a local way. ;)
So, if possible try an easier approach.
You Can Use this Code.. : dateTmiePicker.Value.ToSho rtDateStri ng();
You Can Use this Code.. : dateTmiePicker.Value.ToSho rtDateStri ng();
Open in new window