This topic is locked

Days Calculations between two dates

2/21/2008 1:46:17 PM
PHPRunner General questions
C
ckapote author

Once again I would like to congratulate you for your fantastic software!!!

I have read all posts in your forum but it is not clear how can I take the number of day between two dates and

more specifically .

I have a table with following fields:

Date1 - date

Date2 - date

Date3 - number
I need to find the number of days after adding the Date2 and Date1 .
Please help as I have spent many time looking and testing various with no results.
Thanks

S
spoilar 2/21/2008

depending on what database you are using you could use the datediff() function in your query.
in mysql it would be something like (assuming date1 is your starting date):
datediff(Date1, Date2) as Date3
but in Transact-SQL it would be:
datediff(day, Date1, Date2) as Date3

C
ckapote author 2/22/2008

depending on what database you are using you could use the datediff() function in your query.

in mysql it would be something like (assuming date1 is your starting date):
datediff(Date1, Date2) as Date3
but in Transact-SQL it would be:
datediff(day, Date1, Date2) as Date3


Thanks I use mysql query but I would like to find the number of days ( field Date3) after

I edit or add values in fields in Date1 and Date2 ( Dates ).

Can you please help ?
Thanks

J
Jane 2/22/2008

Hi,
try to use this code in the Before record added/Before record updated event:

$values["Date3"] = (strtotime($values["Date2"])-strtotime($values["Date1"]))/(606024);

C
ckapote author 2/22/2008

Thanks It is working fine !!!!!!! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=26194&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />