473,799 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add 1 Year to current date ?

Syl
I've been through the php.net docs, and this newsgroup - and all seems
to be configured properly, but this statement is still not working:

switch ($level) {
case 1:
$nextyear = mktime(0,0,0,da te("Y")+1,date( "m"),date("d")) ;
$nextyear = strftime("%Y%m% d",$nextyear );
break;

< snip case >

$query = "INSERT INTO users VALUES (NULL, '$username',
password('$user password'), $level, '$fname', '$lname', '$tel',
'$email', '$addr', '$city', '$prov', '$country', '$pcode', 'comm',
'$today', '$nextyear')";

Any ideas ? It's a date field in the table - it displays:
YYYY-MM-DD --> 2005-09-22

Thanks!

Sep 22 '05 #1
6 9321
iuz
Syl wrote:
I've been through the php.net docs, and this newsgroup - and all seems
to be configured properly, but this statement is still not working:

switch ($level) {
case 1:
$nextyear = mktime(0,0,0,da te("Y")+1,date( "m"),date("d")) ;
$nextyear = strftime("%Y%m% d",$nextyear );
break;
date('Y-m-d', 31536000) // this return the next year string (60*60*24*365)
< snip case >

$query = "INSERT INTO users VALUES (NULL, '$username',
password('$user password'), $level, '$fname', '$lname', '$tel',
'$email', '$addr', '$city', '$prov', '$country', '$pcode', 'comm',
'$today', '$nextyear')";

Any ideas ? It's a date field in the table - it displays:
YYYY-MM-DD --> 2005-09-22

Thanks!
by the way in sql is probably better something like.. '$today', date_add(now(), INTERVAL 1 year ))";

leaving the responsability of the year add directly to the dbms..

--
www.iuz-lab.info
Sep 22 '05 #2
>I've been through the php.net docs, and this newsgroup - and all seems
to be configured properly, but this statement is still not working:

switch ($level) {
case 1:
$nextyear = mktime(0,0,0,da te("Y")+1,date( "m"),date("d")) ;
$nextyear = strftime("%Y%m% d",$nextyear );
break;

< snip case >

$query = "INSERT INTO users VALUES (NULL, '$username',
password('$use rpassword'), $level, '$fname', '$lname', '$tel',
'$email', '$addr', '$city', '$prov', '$country', '$pcode', 'comm',
'$today', '$nextyear')";

Any ideas ? It's a date field in the table - it displays:
YYYY-MM-DD --> 2005-09-22


I would replace '$nextyear' in the MySQL query with:
adddate(now(), INTERVAL 1 YEAR)

Gordon L. Burditt
Sep 22 '05 #3
iuz wrote:
Syl wrote:

I've been through the php.net docs, and this newsgroup - and all seems
to be configured properly, but this statement is still not working:

switch ($level) {
case 1:
$nextyear = mktime(0,0,0,da te("Y")+1,date( "m"),date("d")) ;
$nextyear = strftime("%Y%m% d",$nextyear );
break;

date('Y-m-d', 31536000) // this return the next year string (60*60*24*365)


What about on a leap year? ;) I tend to use strtotime for this kind of
thing since it is much easier to read some time down the road:

date('Y-m-d',strtotime('+ 1 year'));

--
Justin Koivisto, ZCE - ju****@koivi.co m
http://koivi.com
Sep 22 '05 #4
If you want to add a year to the current date, then add one to the
year. 2005 + 1 = 2006. It's not rocket science.

Example:

extract(getdate );
$year = $year + 1;
echo "$year-$month-$mday";

Sep 23 '05 #5
Syl
Thanks iUz - I'll give it a go.

I agree re: letting the sql dfo the work, BUT - there are two cases to
resolve boefore the Insert akes place.

has the registered user signed up for one *month* subscription or one
*year* subscription.

That's why I have the case statement.

Thanks agaion to all who replied.

Sep 23 '05 #6
Syl
Awesome.

So - I kept the case statement, but just made two variables to dump
into the insert statement.

Thanks again!

Sep 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
23361
by: ITM | last post by:
Does anyone have an example of an SQL query which returns rows for the year-to-date, but where the "year" commences on August 1st? e.g. select * from mytable where datefield > last august 1st TIA for any help Isabel
13
2351
by: Luigi | last post by:
Imagine I have a small, static, personal site (I do, actually: http://kirpi.it/). And imagine that, just below the title of the page, I would like to have a comment, or a news line, or a birthday reminder, a citation, or whatever you like. At the moment you will find a line that reminds about my small child's second birthday, just as an example. My choice is: a) set it manually every day as I wake up, before breakfast, or b) have it set...
5
3431
by: Larry R Harrison Jr | last post by:
I use the Lebans calendar control and love it; the only thing is that it commonly starts out at the year 1899 rather than the current year. Is there a way to specifically tell it to start at the current date instead? Note: it does this fine if I'm using it in the context of a form's text box, but I'm trying to use it on a module which is called, whereby the date chosen is the date plugged into a variable. Everytime after I reset the...
14
4359
by: Alan | last post by:
Hi everyone! I'm trying to produce a periodic financial report on projects from various departments. My database is set up with the tables tblDepartment, tblProjects, tblPeriods, and tblBudgets -- the first three serve the obvious function; the last table contains foreign keys to tblProjects and tblPeriods, each record corresponding to a project's budget for a particular period. Periods are also grouped by years (a seperate field for...
6
26324
by: vijayk | last post by:
Hi all, I have a field which has data as YYYYMMDD, and I have to find the age of the person by substracting it from current date. can you please please advice... thanks
6
9443
by: phforum | last post by:
If user input the date is 2006-07-01. How to convert it to last year 2005-07-01? Thanks
2
6015
by: rpboll | last post by:
Is there a function that stamps the FISCAL Date (Starting from October)? I am trying to generate a Fiscal Date and an AutoNumber for a key field. Thanks for any suggestions. RBollinger
2
2714
cassbiz
by: cassbiz | last post by:
I am using strtotime and I have read up on some examples and am getting the wrong output, it jumps by several days instead of one day at a time. Ultimately what I am trying to accomplish is to set up an arrival time and a departure time for the script. This is using AJAX (which I am such a newbee @) from my earlier post http://www.thescripts.com/forum/threadnav583131-1-10.html Any help is greatly appreciated. <? $output = '';
3
84901
by: seanw89 | last post by:
I have a bit trouble in converting CURRENT DATE into a integer type as YYYYMMDD. The following script is trying to find a day matching a date column with integer type with yesterday (CURRENT DATE - 1 DAY). = YEAR(CURRENT DATE - 1 DAY) * 10000 + MONTH(CURRENT DATE - 1 DAY) * 100 + DAY(CURRENT DATE - 1 DAY) It doesnt give the correct result. Actually the calculation result from right side of the equation doesnt match with any values in...
5
3232
by: bruce24444 | last post by:
I have a database which assigns warranty claims to people with a main screen showing number of files assigned to each person. The number assigned shows day, week, month and year numbers so they can be evenly distributed. The problem I'm having is getting the query to return a number of files for the current date. Week, month and year appear to work fine. Below are the SQL's for both day and week. Any suggestions as to what's wrong...
0
9544
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10259
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10030
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.