Locating the first day of the month in SQL

Here you'll find a simple way to locate the first day of the month in SQL

I needed to select records for this month so far from the database, which required getting the first day of the

current month. After a while, I worked out the following code. To get the prior 12 months, add "- 12 months" after the "+ 1 day" part. select * from file where indate >= date(curdate() - day(curdate()) days + 1 day)

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Visit the ITKnowledge Exchange and get answers to your developing questions fast.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

This was first published in April 2005

Dig deeper on iSeries SQL commands and statements

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchEnterpriseLinux

SearchDataCenter

Close