dbTalk Databases Forums  

Convert Date to CCYY-MM-DD

comp.databases.sybase comp.databases.sybase


Discuss Convert Date to CCYY-MM-DD in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gary Johnson
 
Posts: n/a

Default Convert Date to CCYY-MM-DD - 12-04-2003 , 09:45 PM






Hi all

Apologies for what appears to be a repeat of previous postings but I
can't seem to get this to work.

I have a date column containing a 29 digit date -
2003-12-05-12.00.00.000000000
I want to use a single SQL select to retrieve this column in the
format 2003-12-05.

I have tried using SUBSTRING to do this but seem to always get NULL
returned.

Help much appreciated!!!

Thanks
Gary

Reply With Quote
  #2  
Old   
Peter
 
Posts: n/a

Default Re: Convert Date to CCYY-MM-DD - 12-05-2003 , 12:51 AM






Hi.

Try something like
select substring(convert(char(10), getdate(), 102),1,4) + '-' +
substring(convert(char(10), getdate(), 102),6,2) + '-' +
substring(convert(char(10), getdate(), 102),9,2) + '-' +





"Gary Johnson" <gc.johnson (AT) virgin (DOT) net> wrote

Quote:
Hi all

Apologies for what appears to be a repeat of previous postings but I
can't seem to get this to work.

I have a date column containing a 29 digit date -
2003-12-05-12.00.00.000000000
I want to use a single SQL select to retrieve this column in the
format 2003-12-05.

I have tried using SUBSTRING to do this but seem to always get NULL
returned.

Help much appreciated!!!

Thanks
Gary



Reply With Quote
  #3  
Old   
Rene van Leeuwen
 
Posts: n/a

Default Re: Convert Date to CCYY-MM-DD - 12-07-2003 , 04:07 PM



In article <4e6f1307.0312041945.63a00f66 (AT) posting (DOT) google.com>, Gary Johnson wrote:
Quote:
Hi all

Apologies for what appears to be a repeat of previous postings but I
can't seem to get this to work.

I have a date column containing a 29 digit date -
2003-12-05-12.00.00.000000000
I want to use a single SQL select to retrieve this column in the
format 2003-12-05.

If you are in ASE 12.5.1
select str_replace(convert(varchar(12),ur_column,111),'/','-') from
ur_table


--
___ _
Quote:
_ \___ _ _ ___//
/ -_) ' \/ -_)
_|_\___|_||_\___|

Reply With Quote
  #4  
Old   
Patti
 
Posts: n/a

Default Re: Convert Date to CCYY-MM-DD - 12-08-2003 , 02:18 PM



Rene van Leeuwen <r.t.j.van.leeuwenNOSPAM (AT) THANKSplanet (DOT) nl> wrote

Quote:
In article <4e6f1307.0312041945.63a00f66 (AT) posting (DOT) google.com>, Gary Johnson wrote:
Hi all

Apologies for what appears to be a repeat of previous postings but I
can't seem to get this to work.

I have a date column containing a 29 digit date -
2003-12-05-12.00.00.000000000
I want to use a single SQL select to retrieve this column in the
format 2003-12-05.

If you are in ASE 12.5.1
select str_replace(convert(varchar(12),ur_column,111),'/','-') from
ur_table
And if you are working IQ 12.5 use:
select dateformat(getdate(),'yyyy-mm-dd')


--Patti


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.