(the data type in database is DateTime, and i just want to store date value
only)
thx.
Hei.
Format the datetime data when you display it to the user.
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q867q
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsbindingclassformattopic.asp
Ken
------------------
"Hei" <chun...@msn.com> wrote in message
news:%23a$RJkn4D...@TK2MSFTNGP12.phx.gbl...
What does "can't" mean? Do you get an error? If so, what is it? What code
are you using?
> (the data type in database is DateTime, and i just want to store date
value
> only)
You can't store just the date. You can insert the date only, but SQL Server
will add the time component.
If you pass just a date, this time component will be midnight. So, when
retrieving, you can use CONVERT to return a formatted "date only" or else
use formatting functions at the client to remove the time from the result.
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
system.date.sqlclient.sqlexception: the conversion of a char data type to
datetime data type resulted in an out -of-range datetime value.
the statement has been terminated.
at system.data.sqlclient.sqlcommand.executeNonQuery()
.....
;
sqlstatement: INSERT INTO Prescription(PrescriptionDate)VALUES ('25/1/2004
0:00:00')
"Aaron Bertrand [MVP]" <aa...@TRASHaspfaq.com> wrote in message
news:eHwDwAr4...@TK2MSFTNGP09.phx.gbl...
Dim dte As Date = Convert.ToDateTime(str)
Insert dte.
Steven
"Hei" <chun...@msn.com> wrote in message
news:uEkpNAx...@TK2MSFTNGP11.phx.gbl...
"Steven Licciardi" <steven_licciar...@hotmail.com> wrote in
message news:uAeRgQx...@TK2MSFTNGP11.phx.gbl...
Try adding the date in the month/day/year format. 1/25/2004
Ken
---------------
"Hei" <chun...@msn.com> wrote in message
news:OLvFjox4...@TK2MSFTNGP12.phx.gbl...
Don't use that format! Blecch!
INSERT INTO Prescription(PrescriptionDate)VALUES ('20040125')
"Ken Tucker [MVP]" <vb...@bellsouth.net> wrote in message
news:%23HdcPrz...@TK2MSFTNGP12.phx.gbl...
thx. is ok right now. but how to change a Date data type to this format?
"Aaron Bertrand [MVP]" <aa...@TRASHaspfaq.com> wrote in message
news:ORpTXsz4...@TK2MSFTNGP12.phx.gbl...
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"Hei" <chun...@msn.com> wrote in message
news:#Y2n7C24...@tk2msftngp13.phx.gbl...
> > sqlstatement: INSERT INTO Prescription(PrescriptionDate)VALUES ('25/1/2004
> > 0:00:00')
>
> Don't use that format! Blecch!
>
> INSERT INTO Prescription(PrescriptionDate)VALUES ('20040125')
Did you misspell '2004-01-25', or are you crusading against the
date/time data type altogether?
In VB, the Format$ string might be "yyyy\-mm\-dd hh\:nn\:ss" .
--
Joe Foster <mailto:jlfoster%40znet.com> Sign the Check! <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above They're coming to
because my cats have apparently learned to type. take me away, ha ha!
No, I did not misspell anything. YYYY-MM-DD is not a safe ISO standard
format in SQL Server (regardless of what Format$ uses in VB, which is
largely irrelevant here anyway). Try this script:
set language french
select 'yours', dateadd(day, 1, '2004-01-25')
select 'mine', dateadd(day, 1, '20040125')
go
select isdate('2004-01-25')
select isdate('20040125')
set language english
select 'yours', dateadd(day, 1, '2004-01-25')
select 'mine', dateadd(day, 1, '20040125')
go
select isdate('2004-01-25')
select isdate('20040125')
I think you can get datetime confusions when operating systems are set up
different to what the user expects. US or UK format for instance. But I've
never tested that so I'm not sure.
Steven
"Hei" <chun...@msn.com> wrote in message
news:umQBNB24...@TK2MSFTNGP12.phx.gbl...
In what manner can an ISO date (or datetime) be mis-construed by any system
to be other then that intended. After all, that *is* the purpose of the ISO
format.
The following works fine:
set language french
select 'mine', dateadd(day, 1, '20040125')
go
select isdate('20040125')
set language italian
select 'mine', dateadd(day, 1, '20040125')
go
select isdate('20040125')
set language german
select 'mine', dateadd(day, 1, '20040125')
go
select isdate('20040125')
set language english
select 'mine', dateadd(day, 1, '20040125')
go
select isdate('20040125')
The only issue I can see is that SQL Server 2000 doesn't like the '-' in
non-English language settings but the dates without the '-' worked fine in
all languages that I have tested.
Perhaps I misread the intent of your post?
Chris.
HTH,
--
Greg Low (MVP)
MSDE Manager SQL Tools
www.whitebearconsulting.com
"Steven Licciardi" <steven_licciar...@hotmail.com> wrote in
message news:Oo$78B%234DH...@TK2MSFTNGP11.phx.gbl...
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"Chris Barber" <ch...@blue-canoe.co.uk.NOSPAM> wrote in message
news:ehzmh9#4DHA...@TK2MSFTNGP12.phx.gbl...
I must admit that I wasn't aware of the '-' issue with SQL Server in
non-English form - I'll have to change my own scripts to fix that.
Thanks.
Chris.
"Aaron Bertrand [MVP]" <aa...@TRASHaspfaq.com> wrote in message
news:ONGA9SA5...@TK2MSFTNGP09.phx.gbl...