Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Current Date 2

Status
Not open for further replies.

Kreiss

Programmer
Oct 8, 2003
48
US
In DB2 is there a way to return the current date only once. When I say.... Select current date from ???? it returns the current date for each record in the table. Is there a way only to get the current date once?

Thanks in advance,
Kacy
 
Kreiss,

SYSIBM.SYSDUMMY1 has been set up specifically for this type of thing.

Use SYSIBM.SYSDUMMY1 as the table your selecting from and you'll only get 1 row.

Cheers
Greg
 
Thanks Greg!
Exactly what I was looking for.

Kacy
 
Hi Kacy,

you need something like this:

SELECT CURRENT DATE
FROM SYSIBM.SYSDUMMY1;

You may also find this useful...

SELECT CURRENT DATE - (DAY (CURRENT DATE)) DAYS

gives you the last day of the previous month.

The first day of this month is
CURRENT DATE - (DAY(CURRENT DATE) - 1) DAYS


the last day of this month is
(CURRENT DATE + 1 MONTH ) - (DAY(CURRENT DATE + 1 MONTH)) DAYS


and the last day of this year is
CURRENT DATE + (12 - MONTH(CURRENT DATE)) MONTHS
+ (31 - DAY(CURRENT DATE)) DAYS


Cheers
Zeat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top