SetDate



SetDate

Setdate Function

Design and Implement a class called Date that has data members to store month (as a number), day, year, and name of the month. The class should have a three-parameter constructor that allows the data to be set at the time of new Data object instances are created. Default constructor that does not take any parameters should set the default values of 1(month),1(day),2001(year). The class should have following three member functions to display date following formats
showDate1() should display the date in 1/1/2001 format
showDate2() should display the date in January 1,2001 format
showDate3() should display the date in 1 January 2001 format
Also the class should have method to set the date(setDate()).This method should take month, day, and year as parameters and set the object instance data member values.
I can not get my code to return the (8, 29, 1986) in the format required by the question.
My Date.h header file:
#include <string>
using namespace std;
class Date {
public:
Date();
Date(int , int, int);
void setMonth(int);
int getMonth();
void setDay(int);
int getDay();
void setYear(int);
int getYear();
void setDate(int, int, int);
int getDate();
void showDate1();
void showDate2();
void showDate3();
private:
int day = 1;
int month = 1;
int year = 2001;
};
My Date.cpp file:
#include <string>
#include <iostream>
#include 'Date.h'
using namespace std;
Date::Date()
{
}
Date::Date(int m, int d, int y)
{
setMonth(m);
setDay(d);
setYear(y);
}
void Date::setDay(int d)
{
day = d;
}
int Date::getDay()
{
return day;
}
void Date::setMonth(int m)
{
month = m;
}
int Date::getMonth()
{
return month;
}
void Date::setYear(int y)
{
year = y;
}
int Date::getYear()
{
return year;
}
void Date::setDate(int m, int d, int y)
{
month = m;
day = d;
year = y;
}
int Date::getDate()
{
return month, day, year;
}
My Assignment5.cpp file:
#include <iostream>
#include <string>
using namespace std;
#include 'Date.h'
int main()
{
Date d1;
Date d2(2, 12, 2010);
// Modified the code so I can see the results
d1.showDate1();
cout << endl;
d2.showDate2();
cout << endl;
d1.setDate(8, 29, 1986);
d2.showDate3();
cout << endl;
system('pause');
return 0;
}
My output is:
1/1/2001
February 12, 2010
12 February 2010
The correct output should be:
1/1/2001
February 12, 2010
29 August 1986
I don't know why my d1.setDate(8, 29, 1986) is not being set. Any help would be greatly appreciated. I have watched alternative videos and read the other posts in this forum but I couldn't find one that helped with this problem. Thanks again.

Setdate

Setdatetime

Setdate Mmdd Hhmm Mmddhhmm Cc Yy.ss

The SetDate method assigns a DateTime value to the buffer column specified by the columnIndex parameter. This method works with the DTDBDATE data type in Integration Services. Void RTCSetDate (uint8t vardayu8, uint8t varmonthu8, uint8t varyearu8) Input Arguments uint8t: Day ( 0x01 - 0x31 ) BCD format uint8t: Month ( 0x01 - 12 ) BCD format uint8t: Year ( 0x00 - 0x99 ) BCD format. To add days to a date in JavaScript, you can use the setDate and getDate methods of the Date object. These methods are used to set and get the day of the month of the Date object. The following example demonstrates how you can add a day to the new instance of JavaScript Date object. Java Date setDate Method. The setDate method of Java Date class sets the day of the month of this date object to the specified argument. This method changes the date object so that it can represent a point in time within the specified day of the month, with the given year, month, hour, minute, and second same as interpreted in the local time zone.