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 |
|
imughal
Posting Yak Master
192 Posts |
Posted - 2005-04-08 : 00:35:41
|
| i have datetime field in sql server. and i used ASP code to insert data. my user enter date in dd/mm/yyyy format. when i save this date in table it's format change to mm/dd/yyyy.i try to work this like month(mydate) & "/" & day(mydate) & "/" & year(mydate)but some time it's work or sometime not. My system date format is dd/mm/yyyy.so tell me how to fix it.thanks |
|
|
rrb
SQLTeam Poet Laureate
1479 Posts |
Posted - 2005-04-08 : 00:46:10
|
you must cast your dates explicitly or you will always have problemsyou need to do something like SQL = "insert into table (datecolumn) values (convert(datetime, '" & Format(mydatevalue, "dd-mmm-yyyy hh:nn:ss") & "'))" Note that it doesn't really matter about which format it is, as long as there is a match between the format specified in the asp Format() function call, and the SQL Convert function call. However, I prefer to use mmm (eg Mar) as this can't be confused. Similarly, you could also use the ISO standard yyyymmdd hhnnss.The format you display or accept in the ASP page is up to you.--I hope that when I die someone will say of me "That guy sure owed me a lot of money" |
 |
|
|
|
|
|