Sybase Date Functions

Sybase Date Functions perform arithmetic operations and display information about datetime, smalldatetime, date and time values.

Function Argument Result
getdate () To get current System date
datename (datepart, date) Part of a datetime, smalldatetime, date or time(String)
datepart (datepart, date) Part of a datetime, smalldatetime, date or time(Integer)
datediff (datepart, date, date) To get difference between dates as months/daya/hours
dateadd (datepart, number,
date)
To add date parts by another date

Examples:

To get current date in Sybase

1> select getdate()
2> go
——————————-
May 24 2016 7:17AM

How to get only of the date in Sybase(string)

1> select datename(mm,getdate())
2> go
————————————————————
May

How to get only of the date in Sybase(integer value)

1> select datepart(mm,getdate())
2> go
———–
5

How to get numbers months between current system date and 03-04-1982 in Sybase

1> select datediff(mm,’03-04-1982′,getdate())
2> go
———–
410

How to get date of 100 months later in Sybase

1> select dateadd(mm,100,getdate())
2> go
——————————-
Sep 24 2024 7:33AM

Powered by k2schools