473,326 Members | 2,124 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,326 software developers and data experts.

PHP & MS Access Date

114 100+
Hello everybody, i m working on PHP and MS Access DB. actually i have the date problem. Pls view my code below:
Expand|Select|Wrap|Line Numbers
  1. $completedate=$query->fields['ComplDate']->Value;
  2. $compdate=date('d-m-Y',$completedate);
  3. $currentdate=strtotime("now");
  4. $currdate=date('d-m-Y',$currentdate);
  5.  
  6. if($compdate=<$currdate)
  7.  {
  8. print "<td width='8%' style='BORDER-RIGHT: #009900 1px solid; BORDER-TOP: #009900 1px solid; BORDER-LEFT: #009900 1px solid; BORDER-BOTTOM: #009900 1px solid' align='center'><font size='2'>" ."Completed"."</font></td>";
  9.  }
  10. else{
  11. print "<td width='8%' style='BORDER-RIGHT: #009900 1px solid; BORDER-TOP: #009900 1px solid; BORDER-LEFT: #009900 1px solid; BORDER-BOTTOM: #009900 1px solid' align='center'><font size='2'>"."Ongoing"."</font></td>";
  12. }
  13.  
Infact i want to print "Completed" if the ComplDate from database is less than or equal to todays date and vice versa. But the problem is that it doesnt give me the appropiate output. Pls help me where am i mistaken?
Oct 4 '07 #1
5 3425
nathj
938 Expert 512MB
Hello everybody, i m working on PHP and MS Access DB. actually i have the date problem. Pls view my code below:

$completedate=$query->fields['ComplDate']->Value;
$compdate=date('d-m-Y',$completedate);
$currentdate=strtotime("now");
$currdate=date('d-m-Y',$currentdate);

if($compdate=<$currdate)
{
print "<td width='8%' style='BORDER-RIGHT: #009900 1px solid; BORDER-TOP: #009900 1px solid; BORDER-LEFT: #009900 1px solid; BORDER-BOTTOM: #009900 1px solid' align='center'><font size='2'>" ."Completed"."</font></td>";
}
else{
print "<td width='8%' style='BORDER-RIGHT: #009900 1px solid; BORDER-TOP: #009900 1px solid; BORDER-LEFT: #009900 1px solid; BORDER-BOTTOM: #009900 1px solid' align='center'><font size='2'>"."Ongoing"."</font></td>";
}

Infact i want to print "Completed" if the ComplDate from database is less than or equal to todays date and vice versa. But the problem is that it doesnt give me the appropiate output. Pls help me where am i mistaken?
Hi,

To set a php variable to the current date all you need is:
[php]
$currentdate = date("Y-m-d"); // this will give 2007-10-04
[/php]

Check out the manual on the date function and you'll see that you can make the variable format match the data format. This should help you out.

The other ting to do to checck the format is to simply echo them both to the browser so that you can see if they match and what differences there are, this will help you to track down any formatting issues.
[php]
$currentdate = date("Y-m-d"); // this will give 2007-10-04
echo $currentdate ;
$completedate=$query->fields['ComplDate']->Value;
echo $completedate ;
[/php]

Have a play around with that and if you get stuck post back.

Cheers
nathj
Oct 4 '07 #2
raaman rai
114 100+
I followed u but still it doesnt work. the echo method returns the dates in same format but when it comes to the if condition the work is not done. i think we need to make the timestamp of the date function also of the same format but infact i dont have any idea on it.

and one more thing if i try to change the condition in the if condition (i.e if($completedate=<$currentdate)) it generates error.

so pls help me further.

Hi,

To set a php variable to the current date all you need is:
[php]
$currentdate = date("Y-m-d"); // this will give 2007-10-04
[/php]

Check out the manual on the date function and you'll see that you can make the variable format match the data format. This should help you out.

The other ting to do to checck the format is to simply echo them both to the browser so that you can see if they match and what differences there are, this will help you to track down any formatting issues.
[php]
$currentdate = date("Y-m-d"); // this will give 2007-10-04
echo $currentdate ;
$completedate=$query->fields['ComplDate']->Value;
echo $completedate ;
[/php]

Have a play around with that and if you get stuck post back.

Cheers
nathj
Oct 4 '07 #3
nathj
938 Expert 512MB
I followed u but still it doesnt work. the echo method returns the dates in same format
Please post the code and the results for this, use the code tags for the code.

but when it comes to the if condition the work is not done. i think we need to make the timestamp of the date function also of the same format but infact i dont have any idea on it.
Is the value in the table a datetime value or just a date?
and one more thing if i try to change the condition in the if condition (i.e if($completedate=<$currentdate)) it generates error.
What error do you get? This might give me a better idea of what is happening. Could you also post all the code involved please? Remember to use code tags.

Cheers
nathj
Oct 4 '07 #4
raaman rai
114 100+
Yes the value is of date&time in the database. infact i dont get any error in running the code but the problem is about wrong output. actually if the completed date is greater or equal to today's date then, it should generate "Ongoing" else it should print "Completed". But the output prints "Completed" even if the completed date is somewhere in 2008. So this is the actual problem.

As you suggested to echo the two dates in the browser, i did it and the format echoed is the same still then the code doesnt work properly.

Plus i went into so many forums but i found no article comparing two dates in the way i m doing. so i m confused n dont know what to do.... pls lemme know if u got any idea.


Please post the code and the results for this, use the code tags for the code.


Is the value in the table a datetime value or just a date?

What error do you get? This might give me a better idea of what is happening. Could you also post all the code involved please? Remember to use code tags.

Cheers
nathj
Oct 4 '07 #5
raaman rai
114 100+
hello there, this is to inform you tht i found out the solution. infact the answer is silly & stupid. i just made the following changes n it worked:

[PHP]
$todaysdate = date("y-m-d");
$cdate=date('y-m-d',$query->fields['ComplDate']->Value);
$currentdate=strtotime($todaysdate);
$completedate=strtotime($cdate);
[/PHP]

hope this helps u too. Ny way thanku somuch for your kind support. we will c again.
Oct 5 '07 #6

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

Similar topics

0
by: Nick Thurn | last post by:
Folks, I'm trying to define a oracle Java Stored Proc interface to an existing timeseries database. Series are accessed by name and are returned as vectors of type pairs, specifically (Date,...
4
by: kinne | last post by:
The following code is supposed to reverse the date in "yyyy-mm-dd" format, but it produces different results in Firefox 1.0 and in Internet Explorer 6SP1. In Firefox, the result is correct...
3
by: Atreju | last post by:
I have the need to import logs into an Access table. The first field is a date & time field, represented in this example: 05/15/2004 17:58:55.336 This is how the logs are reported. DateTime....
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
9
by: Ray | last post by:
I need to convert the normal calendar to show the week no., the period no. and the financial year. The financial year format is as follows:- Date start: 2 May, 2005 7 days a week, 4 weeks a...
1
by: John | last post by:
Hi I am using and access datetime field to store both date & time. How can I split it into date & time after reading the field and then combine the date & time back into datetime when storing...
6
by: Mike Charney | last post by:
Is there a way to check a files date and time stamp from VBA in access. I have a need check a date stamp on a file that I am importing. Thanks in advance, Mike m charney at dunlap hospital...
3
by: divya | last post by:
Hi, I have a table tblbwday with 2 fields Name and Birthday.I have written this script for displaying evryday names of the people on that day. <% set objConn...
16
by: Mik | last post by:
I apologise if this post seems a little basic, but I am a newbie and have NO access knowledge. I have downloaded the Accounts Ledger from the Microsoft Website. It allows the user to review a...
0
by: Vijay | last post by:
Prep Courses for International Certifications, CSTE & CSQA & ISEB & ISTQB &Business Analyst & SOA Certifications in HYDERABAD. After receiving overwhelming response to our last 50+ batches, ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.