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
 to_char sql equivalent

Author  Topic 

kdnichols
Posting Yak Master

232 Posts

Posted - 2007-02-15 : 10:57:32
Hello,

What is the sql equivalent of to_char?

Here is a line of code I am trying to fix.


ELSE to_char(COMPLET, 'DD-MM-YYYY') end)COMPLETE, DESCRIPTION, NAME, ADDRESS, JOB, TYP, NUM, OPR, sum(QTYW) QTY, sum(NCommissionAUT) CommissionAUT


Is there anything else in this line of code that I might need to change?

Thanks,

Kurt

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-15 : 11:00:36
It is much easier with full query, but I believe this is what you want done.

ELSE to_char(COMPLET, 'DD-MM-YYYY') END
ELSE CONVERT(VARCHAR, COMPLETE, 105) END


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-15 : 11:01:30
If COMPLETE column not already is DATETIME column, use this

ELSE CONVERT(VARCHAR, CAST(COMPLETE AS DATETIME), 105) END


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

kdnichols
Posting Yak Master

232 Posts

Posted - 2007-02-15 : 11:09:54
Hello Peso,

Thanks that appears to have fixed it.

Any idea on the substr command?

Kurt
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-15 : 11:13:13
quote:
Any idea on the substr command?

Don't you have the Books Online installed ?


KH

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-15 : 12:27:09
SUBSTR?
You mean SUBSTRING function?

There are a lot of good books for ORACLE programmers who wants to go T-SQL instead.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-02-15 : 23:08:46
Also you may find following link useful:

[url]http://www.microsoft.com/technet/prodtechnol/sql/2000/reskit/part2/c0761.mspx?mfr=true[/url]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -