Thank you both for replies.

Yes, I felt the same that I am missing some file. I am using Wire.h and RTClib.h in my code ... where will I get the DateTime.h library from ?

I know that following code does not give a pro look, please never mind it.

#include <Wire.h>

#include "RTClib.h"

RTC_DS1307 RTC;

int pwr = A3; // setting pwr

int grd = A2; // and grd for Real Time Clock (RTC)

short DN; // Returns the number of day in the year

short WN; // Returns the number of the week in the year

unsigned int yr;

unsigned int mth;

unsigned int dy;

unsigned int w;

unsigned int yy; // ten of year e.g 1 in 2013

unsigned int y; // unit of year e.g 3 in 2013

unsigned int mm; // ten of month e.g 1 in 12

unsigned int m; // unit of month e.g 2 in 12

unsigned int dd; // ten of day e.g 2 in 25

unsigned int d; // unit of day e.g 5 in 25

int days[]={0,31,59,90,120,151,181,212,243,273,304,334}; // Number of days at the beginning of the month in a non leap year.

void setup ()

{

pinMode(pwr, OUTPUT);

pinMode(grd, OUTPUT);

digitalWrite(pwr, HIGH);

digitalWrite(grd, LOW);

Serial.begin(9600);

Wire.begin();

RTC.begin();

// following line sets the RTC to the date & time this sketch was compiled

//RTC.adjust(DateTime(__DATE__, __TIME__));

}

void loop () {

DateTime now = RTC.now();

yr=(now.year());

mth=(now.month());

dy=(now.day());

// calculating week number refer http://en.wikipedia.org/wiki/ISO_week_date

if (mth==1 || mth==2){DN = days[(m-1)]+dy;} //(if m=1 OR m=2)calculate the number of days for January or february ( both leap & non-leap)

else if ((yr % 4 == 0 && yr % 100 != 0) || yr % 400 == 0){ //those are the conditions to have a leap year

DN = days[(mth-1)]+dy+1;} // if leap year, calculate in the same way but increasing one day

else {DN = days[(mth-1)]+dy;} //if not a leap year, calculate in the normal way, such as January or February

// Now start to calculate Week number

if (w==0){WN = (DN-7+10)/7;} //if it is sunday (time library returns 0)

else{

WN = (DN-w+10)/7; } // for the other days of week

{

yy = (yr % 100) / 10; // getting tens of year

y = (yr % 10); // getting unit of year

mm = (mth % 100) / 10; // getting tens of month

m = (mth % 10); // getting unit of month

dd = (dy % 100) / 10; // getting tens of days

d = (dy % 10); // getting unit of day

}

Serial.print("weekno: ");

Serial.print(WN);

delay (1000);

}