#include<stdio.h>
#include<conio.h>
#include<time.h>
time_t time(time_t *t);
main()
{
int y2,m2,d2,y,m,d;
time_t t = time(NULL);
struct tm tm = *localtime(&t);
printf("Time now: %d-%d-%d %d:%d:%d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
y2=tm.tm_year+1900;
m2=tm.tm_mon+1;
d2=tm.tm_mday;
printf("Enter the Reference Date in DD MM YY format\n");
scanf("%d%d%d",&d,&m,&y);
int loop,total_days = 0,days_in_a_year;
int day,month,year;
int month_days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
printf("\n%d\n%d\n%d\n",(y2-y),(m2-m),(d2-d));
printf("%d",month_days[m]);
if(((y2-y)==0&&(m2-m)<1&&(d2<d))(y2<y)(m<1)(m>12)(d<0)(d>month_days[m-1]))
{
printf("\nInvalid Reference Date\n");
}
else
{
total_days=month_days[m-1]-d;
if((m==2)&&((y%4)==0))
total_days+=1;
for(int i=m;i<12;i++)
{
if((y%4==0)&&i==1)
total_days+=1;
total_days+=month_days[i];
}
for(int year=y+1;year<y2;year++)
{
if(year%4==0)
total_days+=366;
else
total_days+=365;
}
for(int i=0;i<m2-1;i++)
{
if((y2%4==0)&&i==1)
total_days+=1;
total_days+=month_days[i];
}
total_days+=d2;
if((y2==y)&&(y%4==0))
total_days-=366;
if((y2==y)&&(y%4!=0))
total_days-=365;
}
printf("\nThe date difference is %d\n",total_days);
getch();
}
To calculate the number of days between given dates, you could calculate the Julian date of each date and then subtract.
http://en.wikipedia.org/wiki/Julian_date
Problem is that this may be inconsistent depending on century is being considered, and what convention is used, because conventions have changed over the centuries.
In the simple case, you could consider that a non leap year is 365 days, and that leap year (366 days) are years evenly divisible by four, except that a century year must be divisible by 400 to be considered a leap year. Then you consider the year, month, and day, adding the number of days in the months preceeding the month in question.
Even that "simple" definition introduces inconsistency, because the year 1600 is leap except in the UK. (There is more to it than that, but the point is made)
Program to compute difference between two dates
#include<stdio.h>
#include<math.h>
void main()
{
int day1,mon1,year1,day2,mon2,year2;
int ref,dd1,dd2,i;
clrscr();
printf("Enter first day, month, year");
scanf("%d%d%d",&day1,&mon1,&year1);
scanf("%d%d%d",&day2,&mon2,&year2);
ref = year1;
if(year2<year1)
ref = year2;
dd1=0;
dd1=func1(mon1);
for(i=ref;i<year1;i++)
{
if(i%4==0)
dd1+=1;
}
dd1=dd1+day1+(year1-ref)*365;
printf("No. of days of first date fronm the Jan 1 %d= %d",year1,dd1);
/* Count for additional days due to leap years*/
dd2=0;
for(i=ref;i<year2;i++)
{
if(i%4==0)
dd2+=1;
}
dd2=func1(mon2)+dd2+day2+((year2-ref)*365);
printf("No. of days from the reference year's first Jan = %d",dd2);
printf("Therefore, diff between the two dates is %d",abs(dd2-dd1));
getch();
}
int func1(x) //x for month y for dd
{ int y=0;
switch(x)
{
case 1: y=0; break;
case 2: y=31; break;
case 3: y=59; break;
case 4: y=90; break;
case 5: y=120;break;
case 6: y=151; break;
case 7: y=181; break;
case 8: y=212; break;
case 9: y=243; break;
case 10:y=273; break;
case 11:y=304; break;
case 12:y=334; break;
default: printf("Error encountered"); exit(1);
}
return(y);
}
#include<stdio.h> #include<conio.h> void main() { int n; printf("enter the value of n"); scanf("%d",&n); switch(n) { case1:printf("monday"); break; case2:printf("tueday"); break; case3:printf("wednesday"); break; case4:printf("thursday"); break; case5:printf("friday"); break; case6:printf("saturday"); break; case7:printf("sunday"); break; default:printf("invalid number"); } }
Keeping accurate records including specific dates of the invention process is important because it demonstrates, and possibly proves, original work. It can mean the difference between getting credit for a invention and credit being given to another for announcing it earlier even though they used your work. It can also be a decisive factor in determining who gets a patent and benefits financially for an invention.
september
dates back to 4,00 b.c.
You declare it by this: Dim var as integer or Public var as integer You can use other types instead of integer like long, double, string, byte etc. Using Public is for making a variable accessible from everywhere and using Dim is for making it accessible only from where you declared it from. For using the variable you just type: var = 1 var = "something" var = 5 + 10 * (2 - 3) var = var & "abc" var &= "abc" In each case the variable will have these values: 1 something -15 Whatever var had before plus abc Again whatever var had before plus abc These are the basics of using a variable
For Excel:Format A1 and A2 in the date format you prefer.Put your first date in A1 and your second date in A2.In A3, put the following formula: =A2-A1Observe the number of days between the two dates displayed in A3.
-- Calculate the total number of years between those dates. -- That number will be reasonably close to the answer itself, since "orbit the sun" is just a more technical term for "year". A more accurate figure will involve the considerable tinkering with the calendar that went on during that period. The simple (140 + 1543) might not be accurate, but the first step given above still holds: Calculate the actual total number of years between those dates, and you'll have the number you're looking for.
Use excel. You need two cells with the dates in them (one with hire date, one with "=TODAY()" in it). Then to calculate the number of days (x), subtract one from the other. You can then create formulae to calculate number of years (=x/365), weeks (=x/7).
-- If the earlier date is in A1 and the later date is in B1, then the number of days between the dates is just [ = B1 - A1 ]. -- Format the cell with [ = B1 - A1 ] in it to display [ number / zero decimal places ]. -- Under [ File / Options / Advanced / ], find the choice on the big list there that says "Display zero in cells with zero value" and check the box.
Information about a time calculator and what it is capable of doing can be found on the internet. Time calculators work strictly with dates and times to calculate total time or to calculate the difference between dates and times.
There are 436 days, inclusive of the dates given.
C program for comparison of dates using structures
Arithmetic works with dates and displays the results as days, so just multiply the result times 24 to get the approximate number of hours between the dates (Excel default format for dates assumes each day has a full 24 hours). If your oldest date is in A1 and your most recent date is in A2, use the following formula to calculate hours between the two dates: =(A2-A1)*24.If you need to show exact hours between specific times for two dates, just format A1 and A2 to display both date and time (a standard option under cell format for dates SAMPLE: 1/1/09 12:00 AM).
Your serial number dates it to between 1976 and 1977.
You can easily do this with Microsoft Excel or OpenOffice's spreadsheet module.
He was in a number of jails between 1916 and 1919 and was released and escaped on various dates.He was in a number of jails between 1916 and 1919 and was released and escaped on various dates.He was in a number of jails between 1916 and 1919 and was released and escaped on various dates.He was in a number of jails between 1916 and 1919 and was released and escaped on various dates.He was in a number of jails between 1916 and 1919 and was released and escaped on various dates.He was in a number of jails between 1916 and 1919 and was released and escaped on various dates.He was in a number of jails between 1916 and 1919 and was released and escaped on various dates.He was in a number of jails between 1916 and 1919 and was released and escaped on various dates.He was in a number of jails between 1916 and 1919 and was released and escaped on various dates.He was in a number of jails between 1916 and 1919 and was released and escaped on various dates.He was in a number of jails between 1916 and 1919 and was released and escaped on various dates.
DATEDIF function computes the difference between two dates in a variety of different intervals, such as the number of years, months, or days between the dates.Syntax for DATEDIF: =DATEDIF(Date1, Date2, Interval)Date1 = first dateDate2 = second dateInterval = interval typeInterval Types:m = Months (complete calendar months between dates)d = Days (number of days between dates)y = Years (complete calendar years between dates)ym = Months Excluding Years (complete calendar months between dates like they were in the same year)yd = Days Excluding Years (complete calendar days between dates like they were in the same year)MD = Days Excluding Years And Months (complete calendar days between dates like they were in the same month and same year)