Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2009-03-03 : 02:39:29
|
| helloI found that wrong time part (AM/PM) in db timestamp.I pass Datetime.Now from C# (eg. 3/25/2009 3:33:04 PM ) but it's inserted in db like ( 3/25/2009 3:33:04 AM) May i know what's wrong ?Thanks |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-03-03 : 03:16:47
|
| see thisselect '3/25/2009 3:33:04 PM',convert(varchar,'3/25/2009 3:33:04 PM'),convert(datetime,'3/25/2009 3:33:04 PM') |
 |
|
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2009-03-03 : 07:23:59
|
HelloThanks for ur reply butI dont get what u mean.What's the cause of that problem and how can i solve itquote: Originally posted by bklr see thisselect '3/25/2009 3:33:04 PM',convert(varchar,'3/25/2009 3:33:04 PM'),convert(datetime,'3/25/2009 3:33:04 PM')
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-03-03 : 07:29:20
|
It seems the datetime information is truncated when you post the value to the database.You are not using DATETIME parameter, are you?When you truncate datetime information before AM/PM part, but after seconds, you will get AM as default. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2009-03-03 : 07:41:40
|
Problem resolved!It is because i format that datetime in front end before inserting.Thanks .quote: Originally posted by Peso It seems the datetime information is truncated when you post the value to the database.You are not using DATETIME parameter, are you?When you truncate datetime information before AM/PM part, but after seconds, you will get AM as default. E 12°55'05.63"N 56°04'39.26"
|
 |
|
|
ddramireddy
Yak Posting Veteran
81 Posts |
Posted - 2009-03-03 : 07:45:51
|
| I think currently your column datatype is varchar, Use datetime type instead of varchar for better usage of those dates. So change that column to datetime datatype and try to insert date into that datatype. then there will not be any problem of AM/PM. And also you will not have any problems with datetime manipulations.We can't expect the problem. May be i think when passing to the DB only, some where data is changing |
 |
|
|
ddramireddy
Yak Posting Veteran
81 Posts |
Posted - 2009-03-03 : 07:45:52
|
| I think currently your column datatype is varchar, Use datetime type instead of varchar for better usage of those dates. So change that column to datetime datatype and try to insert date into that datatype. then there will not be any problem of AM/PM. And also you will not have any problems with datetime manipulations.We can't expect the problem. May be i think when passing to the DB only, some where data is changing |
 |
|
|
|
|
|
|
|