ODBC scalar functions – DATE , TIME and Interval functions

You know very well how to return current date and time using getdate() function. Did you know that there exists ODBC function to return the same?

Select getdate()

returns current date and time

The scalar function

select {fn now()}

also returns current date and time

You can use get month, hour, day, etc using EXTRACT interval function

select {fn extract(month from getdate())}

returns the current month

select {fn extract(day from getdate())}

returns current day value

Here are some functions to explore. These are self-explanatory

select {fn current_date()}
select {fn current_time()}
select {fn now()}
select {fn extract(hour from getdate())}
select {fn extract(minute from getdate())}
select {fn extract(second from getdate())}
select {fn extract(day from getdate())}
select {fn extract(month from getdate())}
select {fn extract(year from getdate())}
select {fn dayname(GetDate())}
select {fn monthname(GetDate())}
select {fn month(GetDate())}
select {fn year(GetDate())}

 

Advertisements

3 thoughts on “ODBC scalar functions – DATE , TIME and Interval functions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s