Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 16, 2012 04:18 AM by Decker Dong - MSFT
Member
52 Points
221 Posts
Dec 16, 2012 01:20 AM|LINK
hi decker
i', still got same error the error is
the conversion of a nvarchar data type to datetime type resulted in an out-of range value
to make you clear abour this i provide to you a bit details information
on my formview i setup the date field into this format {0:dd-MM-yyyy}
on my date database the data type is datetime
i think during my update i need to convert the field date into datetime type,
but i don't know to do that, i provide to you my update query below:
Mydate is date that i want to convert
UPDATE KesalahanDisiplin SET KategoriKes = @KategoriKes, SubKes = @SubKes, Jam = @Jam, Minit = @Minit, Waktu = @Waktu, MyDate = @Mydate, TempatKejadian = @TempatKejadian, PuncaSalahLaku = @PuncaSalahLaku, SiaranMedia = @SiaranMedia, KeteranganKes = @KeteranganKes, PengesahanDisiplin = @PengesahanDisiplin, MaklumIbuBapa = @MaklumIbuBapa, TindakanPenjaga = @TindakanPenjaga WHERE (IdKesalahan = @IdKesalahan)
All-Star
118619 Points
18779 Posts
Dec 16, 2012 01:22 AM|LINK
afastars the conversion of a nvarchar data type to datetime type resulted in an out-of range value
I mean you should bind the TextBox to the AJAX-based Control which force you to do that formation, and save that in the db with DateTime column.
Dec 16, 2012 01:35 AM|LINK
i already bind as you said, i this information may help us:
when i'm in editing mode, as usual i choose my desire day month and year
what happen is that the formview format is mm-dd-yyyy even i already setup the format to {0:dd-MM-yyyy}
for example: is i choose this date 12-12-2012 i can update without any error
but if i choose 13-12-2-2012 i got this error the conversion of a nvarchar data type to datetime type resulted in an out-of range value
means that the formview format is MM-dd-yyyy that is why i got that error...do you have any idea to resolve this...
i also already setup the ajax calendar format date into this format dd-MM-yyyy
i think i need to convert it into date time during update...please correct me i'm new in this
Dec 16, 2012 01:55 AM|LINK
i find something, when i setup the ajax calendar format into MM-dd-yyyy i can update without any error
but if use this format dd-MM-yyyy i got error as i send previously...do you have any ideas regading this..?
Contributor
3970 Points
1096 Posts
Dec 16, 2012 03:14 AM|LINK
afastars hi Dan Bracuk i think i got an idea, during the upate can i convert the date format as what i want...?
i think i got an idea, during the upate can i convert the date format as what i want...?
I think you are better off converting the string to a date first, and sending the date to your query as a parameter.
Dec 16, 2012 03:41 AM|LINK
how to do that..? can i convert during update..? because the problem is, when i want to update the data, got that error
so i assume that need to convert during update if can please let me know
i'm new in sql command , i attach again my update command
MYDATE is a date
UPDATE KesalahanDisiplin SET KategoriKes = @KategoriKes, SubKes = @SubKes, Jam = @Jam, Minit = @Minit, Waktu = @Waktu, MYDATE = @MYDATE, TempatKejadian = @TempatKejadian, PuncaSalahLaku = @PuncaSalahLaku, SiaranMedia = @SiaranMedia, KeteranganKes = @KeteranganKes, PengesahanDisiplin = @PengesahanDisiplin, MaklumIbuBapa = @MaklumIbuBapa, TindakanPenjaga = @TindakanPenjaga WHERE (IdKesalahan = @IdKesalahan)
Dec 16, 2012 04:18 AM|LINK
afastars afastars
Please make sure that you Text can be convertable to DateTime, and then use:
DateTime.Parse method to convert your string to a correct DateTime-based type.
And then do inserting.
afastars
Member
52 Points
221 Posts
Re: Change Date Format Before Insert Into Database
Dec 16, 2012 01:20 AM|LINK
hi decker
i', still got same error the error is
the conversion of a nvarchar data type to datetime type resulted
in an out-of range value
to make you clear abour this i provide to you a bit details information
on my formview i setup the date field into this format {0:dd-MM-yyyy}
on my date database the data type is datetime
i think during my update i need to convert the field date into datetime type,
but i don't know to do that, i provide to you my update query below:
Mydate is date that i want to convert
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Change Date Format Before Insert Into Database
Dec 16, 2012 01:22 AM|LINK
I mean you should bind the TextBox to the AJAX-based Control which force you to do that formation, and save that in the db with DateTime column.
afastars
Member
52 Points
221 Posts
Re: Change Date Format Before Insert Into Database
Dec 16, 2012 01:35 AM|LINK
hi decker
i already bind as you said, i this information may help us:
when i'm in editing mode, as usual i choose my desire day month and year
what happen is that the formview format is mm-dd-yyyy even i already setup the format to {0:dd-MM-yyyy}
for example: is i choose this date 12-12-2012 i can update without any error
but if i choose 13-12-2-2012 i got this error the conversion of a nvarchar data type to datetime type resulted
in an out-of range value
means that the formview format is MM-dd-yyyy that is why i got that error...do you have any idea to resolve this...
i also already setup the ajax calendar format date into this format dd-MM-yyyy
i think i need to convert it into date time during update...please correct me i'm new in this
afastars
Member
52 Points
221 Posts
Re: Change Date Format Before Insert Into Database
Dec 16, 2012 01:55 AM|LINK
hi decker
i find something, when i setup the ajax calendar format into MM-dd-yyyy i can update without any error
but if use this format dd-MM-yyyy i got error as i send previously...do you have any ideas regading this..?
Dan Bracuk
Contributor
3970 Points
1096 Posts
Re: Change Date Format Before Insert Into Database
Dec 16, 2012 03:14 AM|LINK
I think you are better off converting the string to a date first, and sending the date to your query as a parameter.
afastars
Member
52 Points
221 Posts
Re: Change Date Format Before Insert Into Database
Dec 16, 2012 03:41 AM|LINK
how to do that..? can i convert during update..? because the problem is, when i want to update the data, got that error
so i assume that need to convert during update if can please let me know
i'm new in sql command , i attach again my update command
MYDATE is a date
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Change Date Format Before Insert Into Database
Dec 16, 2012 04:18 AM|LINK
Please make sure that you Text can be convertable to DateTime, and then use:
DateTime.Parse method to convert your string to a correct DateTime-based type.
And then do inserting.