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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Date problem

Author  Topic 

rjrferreira
Starting Member

13 Posts

Posted - 2007-08-09 : 11:11:27
I

i made an sql statmente with cursor that gets some info. this info contains a date in this format "dd/mm/yyyy" because is a varchar field.

Now i want to copy that info to another field but this field in database are in this format "mm/dd/yyyy"....

so my problem is how to change the first format do the second and update the new info.

i tried yet with convert, but not works

greetings

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-08-09 : 12:06:38
Why are you using varchar to store dates ????

Never store dates in any particular format using string formats. Always simply use the DateTime data type. This the most important and most basic rule of database design. Always, always, always use correct data types in your database designs.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-10 : 01:38:32
1 As said, dont use varchar to store dates. Use DATETIME datatype
2 Create another column with proper DATETIME datatype and update that column by

Update table
set datetime_column=dbo.proper_date(replace(varchar_column,'/',''))
(Use the function from http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=82164)[/code]
3 Let the front end application do the formation

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -