Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Format in YYYY-MM-DD

Status
Not open for further replies.

Autosys

Programmer
Jun 1, 2004
90
GB
Hi there could anyone please help me in getting my date in the format YYYY-MM-DD as none of the below appears to do it Thanks a lot
S

select
convert(varchar, GetDate(), 100) as '100 Conversion',
convert(varchar, GetDate(), 101) as '101 Conversion',
convert(varchar, GetDate(), 102) as '102 Conversion',
convert(varchar, GetDate(), 103) as '103 Conversion',
convert(varchar, GetDate(), 104) as '104 Conversion',
convert(varchar, GetDate(), 105) as '105 Conversion',
convert(varchar, GetDate(), 106) as '106 Conversion',
convert(varchar, GetDate(), 107) as '107 Conversion',
convert(varchar, GetDate(), 108) as '108 Conversion',
convert(varchar, GetDate(), 109) as '109 Conversion',
convert(varchar, GetDate(), 110) as '110 Conversion',
convert(varchar, GetDate(), 111) as '111 Conversion',
convert(varchar, GetDate(), 112) as '112 Conversion',
convert(varchar, GetDate(), 113) as '113 Conversion',
convert(varchar, GetDate(), 114) as '114 Conversion',
convert(varchar, GetDate(), 120) as '120 Conversion',
convert(varchar, GetDate(), 121) as '121 Conversion',
convert(varchar, GetDate(), 126) as '126 Conversion',
convert(varchar, GetDate(), 130) as '130 Conversion',
convert(varchar, GetDate(), 131) as '132 Conversion'
 
Code:
SELECT REPLACE(convert(varchar, GetDate(), 111),'/','-')

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
You need to convert to varchar(10). Try this:

Code:
select convert(varchar(10), getdate(), 120)

Hope it helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
or
Code:
SELECT LEFT(convert(varchar, GetDate(), 120),10)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Try this: CONVERT(CHAR, RECEIVABLE.INVOICE_DATE, 102) if 102 doesn't worked you can try from 100 to ... and replace the field receivable.invoice_date for your field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top