How to know the date is first,second,third weeks...

W

weetat

Hi all,

I have column in the database , release_date . The release_date
column is to capture when the data are first released to our client.

Our client want us to check if for example the release_date is 9
August 2007 is on the first week of the month. However it did not the
referred to month but to release_date.

for example :

Prod reelase_date

A

Thanks

wee tat
 
S

Sherm Pendley

weetat said:
Our client want us to check if for example the release_date is 9
August 2007 is on the first week of the month. However it did not the
referred to month but to release_date.

Have a look at the java.util.Calendar class. For example:

import java.io.*;
import java.util.Calendar;

public class CalendarExample {

public static void main (String argv[]) {
Calendar cal = Calendar.getInstance();
cal.set(2007, 8, 9); /* year, month, day */
System.out.println("Week of Month: " +
cal.get(Calendar.WEEK_OF_MONTH));
}

}

sherm--
 
L

Lew

Sherm said:
weetat said:
Our client want us to check if for example the release_date is 9
August 2007 is on the first week of the month. However it did not the
referred to month but to release_date.

Have a look at the java.util.Calendar class. For example:

import java.io.*;
import java.util.Calendar;

public class CalendarExample {

public static void main (String argv[]) {
Calendar cal = Calendar.getInstance();
cal.set(2007, 8, 9); /* year, month, day */
System.out.println("Week of Month: " +
cal.get(Calendar.WEEK_OF_MONTH));
}

}

Another approach, useful if you have to characterize dates more fully as, for
example, weekday vs. weekend, holidays (perhaps with separate logic for
holidays in different countries), "A" days vs. "B" days or other attributes
not known to java.util.Calendar, is to use a database table of dates. Each
date is tagged with the attributes of interest. Then all you have to do is
SELECT from that table to find out if a given date is a weekend, holiday or
whatever. It also supports queries like "how many non-holiday days are in an
interval, after the first four?"
 
D

Dr J R Stockton

In comp.lang.java.programmer message <1186977085.227438.92670@q3g2000prf
..googlegroups.com>, Sun, 12 Aug 2007 20:51:25, weetat
Our client want us to check if for example the release_date is 9
August 2007 is on the first week of the month.

If that means in the first seven days, check that day-of-month is less
that 8.

Otherwise, you need to say what definition of week you are using -
International Standard, US vernacular, etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top