Problem checking day of week from date

i'm trying to find out the day of the week from a date stored in a database.

i am using smallsql for my database.

s.executeQuery("select * from results");

ResultSet result=s.getResultSet();

result.next();

day=result.getString(1);

System.out.println(day);

sql="select dayofweek({d "+day+"}) from results";

this is the code to read in the date and set up the sql

and this is the code to get the number representing the day of the week

s.executeQuery(sql);

ResultSet result=s.getResultSet();

result.next();

daynum=result.getInt(1);

System.out.println(daynum);

[649 byte] By [alancola] at [2007-11-27 4:47:03]
# 1

Hi

Try to run the same query in SQL Server..if it runs well there then u have some prob in ur code....

and if it throws error then ur query it self is wrong...

try this

select datepart(dw,StartDate) from tablename

or

select datepart (dw, '5/18/2007') as dayOfTheWeek,datename (dw, '5/18/2007') as NameOfDay

///StartDate above is column name ffrom my database..u need to put ur column name...

Good Luck....

hetal_giria at 2007-7-12 9:59:43 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

Hi

Try to run the same query in SQL Server..if it runs well there then u have some prob in ur code....

and if it throws error then ur query it self is wrong...

try this

select datepart(dw,StartDate) from tablename

or

select datepart (dw, '5/18/2007') as dayOfTheWeek,datename (dw, '5/18/2007') as NameOfDay

///StartDate above is column name ffrom my database..u need to put ur column name...

Good Luck....

hetal_giria at 2007-7-12 9:59:43 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...