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
 General SQL Server Forums
 New to SQL Server Programming
 convert 'dd.mm.yyyy' string to mm/dd/yyyy date

Author  Topic 

b00gieman
Starting Member

14 Posts

Posted - 2007-11-30 : 02:30:50
Hi!

Is it possible to convert a 'dd.mm.yyyy' string into an mm/dd/yyyy date using convert or cast?The date format set on the sql server is mm/dd/yyyy...

Thanks!

arorarahul.0688
Posting Yak Master

125 Posts

Posted - 2007-11-30 : 02:49:16
this will work chk it out

select convert(varchar(15),column_name,101) from table


kenw.............

Rahul Arora
MCA 07 Batch
NCCE Israna, Panipat
HRY, INDIA

######################
IMPOSSIBLE = I+M+POSSIBLE
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-30 : 03:20:19
quote:
Originally posted by b00gieman

Hi!

Is it possible to convert a 'dd.mm.yyyy' string into an mm/dd/yyyy date using convert or cast?The date format set on the sql server is mm/dd/yyyy...

Thanks!


1 What is the datatype of the column?
2 Where do you want to show formatted dates?

Madhivanan

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

b00gieman
Starting Member

14 Posts

Posted - 2007-11-30 : 08:31:22
It's like this:

I have an intermediary sql table.I'm importing excel data into this table.My problem is that the date in the excel has the 'dd.mm.yyyy' type.I want to us my intermediary table to update another table.In the other table,the format is 'mm/dd/yyyy'...
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-30 : 10:01:48
quote:
In the other table,the format is 'mm/dd/yyyy'...

Don't tell me the data type for "the other table" is also varchar ?

The data type of "the other table" should datatime. You can use convert(datetime, stagingtable.datecol, 103) to convert to datetime


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

b00gieman
Starting Member

14 Posts

Posted - 2007-11-30 : 14:13:57
no,the other table,the data type is 'smalldatetime'...thx for the suggestion.I'll try that...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-01 : 01:21:01
also check if you have any bad dates

where isdate(col)=1 and len(col)=10

Madhivanan

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

- Advertisement -