Link to home
Start Free TrialLog in
Avatar of yerai
yerai

asked on

read sysdate in visual c++


Hi, i need how read the sysdate in visual c++


Regards

Gerid Garcia
Avatar of List244
List244

#include <iostream>
#include <windows.h> //Used to get system time
using namespace std;

int main()
{
      SYSTEMTIME Time;
      GetSystemTime(&Time);
      return 0;
}

Then you can access members of Time like:
Time.wDay
Time.wDayOfWeek
Time.wMonth
Time.WYear
ASKER CERTIFIED SOLUTION
Avatar of tushar_comp
tushar_comp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am going to have to disagree with MSDN...

Saturday = 0
Sunday = 1
Monday = 2
Tuesday = 3
Wednesday = 4
Thursday = 5
Friday = 6

And the other members which will appear with Time. are as expected.
Actually... no... MSDN is right on that, what is weird however is that for me at least..
WDay returns day+1 instead of day.
Once the time hits 5:00 PM it seems it advances the day.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The solution provided by me at: http://#16679626 and the solution provided by tushar_comp at: http://16679983
both seem to be a little wrong to me.  The solution at: http://#16680050 seems to be better fit.

If you must do a split, I am fine with this, but please select http://#16680050 as the answer.

The previous solutions mine, and the link explaining mine more in depth by Tushar_comp are both lacking in that
the time system seems to be incorrect.  This is explained here: http://#16680000
Repost: (Trying to fix those links)

The solution provided by me at: http:#16679626 and the solution provided by tushar_comp at: http:#16679983
both seem to be a little wrong to me.  The solution at: http:#16680050 seems to be better fit.

If you must do a split, I am fine with this, but please select http:#16680050 as the answer.

The previous solutions mine, and the link explaining mine more in depth by Tushar_comp are both lacking in that
the time system seems to be incorrect.  This is explained here: http:#16680000