Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Filter Query By Year & change dated automatically

Author  Topic 

tdnguyen
Starting Member

2 Posts

Posted - 2014-01-21 : 12:34:24
Hello, I have a data column named Date_In with format of 20-May-13. How can I filter the data to select based on year only. I used

Select 

*

From apps.xdmc_852@erpprod

Where Year(Date_in) = 2014


This code is not working.

I also need a way to automatically update to next week range. For example, last week I used where function like this

Where Date_in = to_date('01/12/2014','MM/DD/YYYY')


Is there a way it will automatically at the next 7 days to the code above when the date is available. This week I have to go back and changed the code in to this:

Where Date_in = to_date('01/19/2014','MM/DD/YYYY')



TDN

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2014-01-21 : 13:48:37
Just to clarify, you have a column called Date_In and that column contain string values of dates formatted like DD-MMM-YY (20-May-13)?

If that is the case, do you have the option of changing that column to a proper date column? That would make like a lot easier.

Plus, it looks like you are using Oracle. This is a SQL Server forum, so you might get better help on a forum specific to Oracle.
Go to Top of Page

tdnguyen
Starting Member

2 Posts

Posted - 2014-01-21 : 13:54:11
Do you know any forums for Oracle?

TDN
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-01-22 : 07:25:21
quote:
Originally posted by tdnguyen

Do you know any forums for Oracle?

TDN


yep
www.orafaq.com
www.dbforums.com

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -