473,394 Members | 1,935 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

getDate function

Hello. I am in need of a method to return the month and day of the month (as a birthday reminder for a friend...thought it'd be a nice little popup). I intend on using this as a comparison,

if ( getdate("%m") == "05" && getdate("%d") == "08" )
...birthday message code...

at least, it looked this easy from from the time.h library. Can someone please guide me as to the correct procedure?

And while I'm here, I may as well ask: what method should I use to have the program add itself to autostart on startup? Want it to be a nice birthday surprise. :)
Mar 10 '07 #1
6 9749
DeMan
1,806 1GB
if ( getdate("%m") == "05" && getdate("%d") == "08" )
...birthday message code...

at least, it looked this easy from from the time.h library. Can someone please guide me as to the correct procedure?
I think you'll find that getDate takes as argument a value of seconds since sometime (probably 01/01/1976 or something) and returns a structure containing elements representing month year etc. (you can use time() to get this value for right now, and pass that into getDate());

as for setting something to run automatically....Can't help you there I'm afraid....
Mar 10 '07 #2
I think you'll find that getDate takes as argument a value of seconds since sometime (probably 01/01/1976 or something) and returns a structure containing elements representing month year etc. (you can use time() to get this value for right now, and pass that into getDate());

as for setting something to run automatically....Can't help you there I'm afraid....
so something like getDate(time(pointer_to_structure)) ?

(as you can see, I'm overtly simple and like to do things the easy way)

if not then surely..

(declare pointer)

int date = time(pointer_to_structure);

getDate(date);
Mar 10 '07 #3
DeMan
1,806 1GB
Sorry, I'm not sure the name of the exact structure, so I'll call it dateStruct here (lookup "date time c" or similar (in google or equiv) for better explanation)....

dateStruct myDate = getDate(time());

then myDate has fields that relate to month, day, year etc whcih you can compare to ....

(you may need to include some other libraries, but your search should clarify this)
Mar 11 '07 #4
Sorry, I'm not sure the name of the exact structure, so I'll call it dateStruct here (lookup "date time c" or similar (in google or equiv) for better explanation)....

dateStruct myDate = getDate(time());

then myDate has fields that relate to month, day, year etc whcih you can compare to ....

(you may need to include some other libraries, but your search should clarify this)

I see..that helps tremendously. Otherwise I might've got the whole thing wrong again. Thank you for your help.
Mar 11 '07 #5
....discovered the "_strdate()"

#include <iostream>
#include <ctime>

using namespace std;

int main(){
char date[9];
_strdate(date);
if ( date == "05/08/07" ){
cout << "Happy Birthday!";
}
cin.get();
}
Mar 11 '07 #6
DeMan
1,806 1GB
Good Stuff!!
Mar 11 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Rajesh Garg | last post by:
Hi, I have written a stored proc with some temporary tables and also used a getdate() in my stored proc. When i try to call the sproc the error is that we can only use extended sprocs or function...
2
by: Konstantin Zakharenko | last post by:
Hello, Our QA team have running a lot of test scripts (for automated regression testing), they run them on the different databases (Oracle/MS SQL). Several of those tests are dependent on the...
10
by: Bill Edwards | last post by:
I'm trying to produce an array of working days but want to force Saturday and Sunday to return the date of the previous Friday, e.g. Sunday 9/12/04 should return Friday 9/10/04 and similarly...
3
by: Yann Laviolette | last post by:
Hi! I look for a function like the Windows function getdate(&d); and gettime(&t); to have the date and the time. Also I look for a function like spawnl to call another program. These function...
1
by: lasek | last post by:
Hi all, Someone can help me ? char compete; //20 char compete contain a 'date value' returned from oracle procedure (Pro*C)and you can imagine his value, for example,"01/01/2005"
6
by: Matik | last post by:
Hi, I have a funny situation. Within: MSSQL 2000 SP3, everything below described is running on same PC. there is a program running, which sends information to two other programs. This...
6
by: FFMG | last post by:
Hi, My timezone is GMT +2 So when I do a $date = getdate( 0 ); I get: $date = {
3
by: Yas | last post by:
Hi, I am creating creating a table with a Date column dd-mm-yyyy. But I cant seem to find a SQL function that just returns today's date. getDate() returns the time as well so I cant use it. ...
1
by: napjohn8 | last post by:
here is my question with getdate function --12. List the names and staff number for staff who manage detached properties that have a current lease i.e. there is a lease and its end date is in the...
7
by: Bassem | last post by:
I'm trying to select all records inserted in a certain day, so comparing date only and ignore the time. I searched for a function but didn't found. I found this: WHERE day() = day(GetDate()) AND...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.