Sybase Date Functions

Posted on 2003-03-27
Medium Priority
Last Modified: 2011-09-20
Does Sybase have year() and month() functions for DATETIME type?
Question by:Johnny2pints
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

DaniPro earned 252 total points
ID: 8220580
The YEARS function return the number of years since the specified date, the number of years between two specified dates or adds the integer-expression amount of years to the specified date.
SELECT YEARS( '1998-07-13 06:07:12' )
returns the value 1998.

The MONTH function returns a number from 1 to 12 corresponding to the month of the given date.
SELECT MONTH( '1998-07-13' )
returns the value 7
LVL 13

Assisted Solution

alpmoon earned 248 total points
ID: 8222927
Month and years are ASA functions. If you are using ASE, you should use datepart function:

select @month = datepart(mm, @yourdate)
select @year = datepart(yy, @yourdate)

datepart(date_part, date)

You can find more details at:


Expert Comment

ID: 8229615
This example clearly explain, how to get year.  Replace ur variable at getdate function (returns system date)

1> select getdate()
2> go                          
        Mar 29 2003 11:49AM
(1 row affected)

1> select datepart(year, getdate())
2> go            
(1 row affected)

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Check out the latest tech news, community articles, and expert highlights in August's newsletter.
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question