sybase: how to retrieve current date in a specific format

To retrieve current date in sybase, simply call “getdate()” as in:

select getdate()

Thinks far more interesting when you make usage of the “convert()” function as well.

For instance, to display current date in the following format: yyyymmdd (with leading zero for both month and day), simply proceed as follow:

select convert(char(8), getdate(), 112)
//output: 20111208 if today is Dec. 8th, 2011

sources

Post a Comment

Your email is never published nor shared. You're allow to say what you want...