SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Date problem
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

13 Posts

Posted - 08/09/2007 :  11:11:27  Show Profile  Reply with Quote

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


Dr. Cross Join

7423 Posts

Posted - 08/09/2007 :  12:06:38  Show Profile  Visit jsmith8858's Homepage  Reply with Quote
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
Go to Top of Page

Premature Yak Congratulator

22847 Posts

Posted - 08/10/2007 :  01:38:32  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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)

3 Let the front end application do the formation


Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000