• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

Date Type..

Hi

this could be a newbie question. I want to assign "12\12\1999" as a date
variable. Is it possible to assign this to type date or whether i have to pass   this to three variables and check for its validity. helps will be very much appreciated.

thanks
begin.
0
begin
Asked:
begin
1 Solution
 
sreenathkCommented:
Which C++ is it? In VC++ there is such an option available.

Sreenath
0
 
KangaRooCommented:
Sreenath, I suppose you mean there are date and time classes in MFC.
There are some date and time functions in C also. Check your manual/helpfile for time.h. Look for the struct tm
0
 
dhymesCommented:
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
sreenathkCommented:
Yes Kangaroo, what you said is correct. What dhymes given also explains how cdate class is implemented. Basically we coming to the same conclusion that it is possible to have a date variable. But where is the initiator? Whether this satisfies him or not?

Sreenath
0
 
sumant032199Commented:
You can use following technic.
time and date are 16-bit structures divided into bit fields for
referring to the current date and time.

 time ¦15.....11¦10........5¦4.......0¦
      ¦---------+-----------+---------¦
        Hours     Minutes    Seconds/2

 date ¦15..........9¦8.....5¦4.......0¦
      ¦-------------+-------+---------¦
       Years since   Month     Day
           1980

If you want a simple code how to access these bit fields then simply make a comment.
0
 
sumant032199Commented:
You can use following technic.
time and date are 16-bit structures divided into bit fields for
referring to the current date and time.

 time ¦15.....11¦10........5¦4.......0¦
      ¦---------+-----------+---------¦
        Hours     Minutes    Seconds/2

 date ¦15..........9¦8.....5¦4.......0¦
      ¦-------------+-------+---------¦
       Years since   Month     Day
           1980

If you want a simple code how to access these bit fields then simply make a comment.
0
 
beginAuthor Commented:
Yes sumant, i need to know about how to access dates using bit fields.
--begin
0
 
sumant032199Commented:
I am very sorry I neglected the entire question. I will give you now.
#define DD(date) (date & 0x1F)
#define MM(date) (date & 0x1E0) >> 5
#define YY(date) (date & 0xFE00)/0x200

#define SEC(time) (time & 0x1F)
#define MIN(time) (time & 0x7E0) >> 5
#define HR(time) (time & 0xF800) >> 11

0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now