teradata simple sql

Posted on 2008-02-06
Medium Priority
Last Modified: 2008-06-09
how do I do the following in teradata:
select * from table
where ship_date between (1st day of previous month) and (last_day of previous month)
Question by:Sara_j_11
  • 2
LVL 50

Expert Comment

ID: 20913511

select * from table
where month(ship_date) = Month(current date - 1 month)
 and year(ship_date) = Year(current date - 1 month)
LVL 50

Accepted Solution

Lowfatspread earned 2000 total points
ID: 20920332
or try this...

select *
from ...
ship_date between add_months(current_date,-1) - extract(day from Add_months(current_date,-1)) + 1
  and add_months(add_months(current_date,-1) - extract(day from Add_months(current_date,-1)) + 1,1) - 1

Author Comment

ID: 20951491
does both of the above posts do the same thing? is there any disadvantage of using post 1?

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

607 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