How to add decimal month to some month in sql, php, perl, bash, sh?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to add decimal month to some month in sql, php, perl, bash, sh?
# 8  
Old 06-03-2014
We're not worried about grammar errors in English if the message is clear., but there is confusion on how we know the length of a month. Could you show us what input & output you would expect and how you are hoping to generate your decimal that you wish to add.
  • Is the decimal in days or months?
  • Is it months.days or month.partmonth, e.g 3.3429 is three months and about 10 days (depending on which month)
We could help you write something that is not what you need, so more explanation with examples of what you expect the answer to be is better.

It's a bit like asking a child "What is 3+4x5=" They may answer 23 or 35. You need to be clear what you actually want and I'm sure we can work on something.


Thanks,
Robin
# 9  
Old 06-03-2014
Some users have services (there are several different costs) and for example Thomas have bought "D3" service for 6 months. After some time he want to improve it to "D4". So now we're calculating his service virtual value (we know when he bought it and when it's ending), we have that there are left 0,5462 value of his paid virtual money. For example at beginning he paid 100 Eur, so there is 54.62 Eur left. "D4" for one month costs 25 Eur. We get: 54,62 / 25 = 2,1848 months. So now we need to add this time 2,1848 months (in minutes accuracy) to current date/time, (but it must consider, that each month has different number of days) and then we will get exact date that "D4" service will expire. Best way to get how many minutes it need to add to current time to get that expiration date. It can be done with php, bash or smth taht would work in linux.
# 10  
Old 06-04-2014
How I can see there is no simple wat to get that.
So, to improve the proccess I can pay for this job by paypal. Please, help me and I will donate for you or forum.
It would be better get the code in php language, but also it can be done in any other language which works in linux.

Thank you for any help
# 11  
Old 06-04-2014
Payment to speed up a response or escalate? Not for me. I'm just confused.

If you have a date, as you suggest and and you need to add 2.1848 months, can you show us what answer you want for a spread of months with various lengths, e.g.
  • 10th February (leap year)
  • 10th February (non-leap)
  • 10th March
  • 10th April
I/we need to know what your business rules are, then we can approach the issue. It would be dangerous for us to assume we know what your customer contracts state.



Robin
# 12  
Old 06-04-2014
Are you sure you know what you/your business is talking about? Usually, a day is a good basic unit for licence payments, which you can count; I can't see the need to calculate to the split second. To make your customer happy, give him the fraction of a day that might be in question.
# 13  
Old 06-04-2014
Agreed, "decimal fraction of a month" makes absolutely no sense no matter how you cut it.

We are not being mean. We are not denying you anything. We are not "holding out on you" for pay or anything else. The concept of "decimal fraction of a month" is incoherent and flawed.

Talk with them about it and get them to redefine it in days, or at least a fixed number of days.
# 14  
Old 06-04-2014
Payment to the person who will finish the script (I need only to get exact expiration date). For example, if there is 2,1848 months, I need to get exact minutes count (2,1848 * 30 * 24 * 60) - 94383 minutes (but don't forget that each month has different number of days). Then mysql in our script will add that minutes ant will get exact expiration date of the service.

Yes, we can count that one month has 30 days, but if customer will buy for example for longer period of time he can loose several days. Also if there would be february with 28 days he will get +2 days for nothing. If they would change service a lot of time, this inaccuracy can become to weeks and etc. So we want to get exact date (if it's possible) depent on calendar
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Bash Display First Friday of the next month

Hello, I need to find the date of next first Friday of the month and set as a variable in a bash script ie - FIRSTFRIDAY=$(date -dfirst-friday +%d) I know date -dfirst-friday doesn't work, but unsure if I can use this / cal + awk or something else to find the right date of the... (7 Replies)
Discussion started by: summerdays
7 Replies

2. Shell Programming and Scripting

Remove new line and convert Month to Decimal

# Sample input common-name www.test.com.au expiration Dec 21 01:00:31 2017 GMT common-name www.test1.com.au expiration Jan 19 04:41:03 2018 GMT # Desired Output # Field 1: Domain name # Field 2: Date/time converted to Austraian format DD/MM/YYYY and on the same line as Domain Name. #... (7 Replies)
Discussion started by: thangbom
7 Replies

3. UNIX for Advanced & Expert Users

To pass one month range in sql script

Hi Guys, i am having .sql script which inserts data from one table to another table based on date condition, i need to pass range on based on how many number of months, for e.g set timing on; whenever sqlerror exit failure; spool myscript.log append accept start_date... (7 Replies)
Discussion started by: rohit_shinez
7 Replies

4. Shell Programming and Scripting

Need last month files after 10th of every month

Hi, I need all file names in a folder which has date >= 10th of last month, Example : files in folder AUTO_F1_20140610.TXT BUTO_F1_20140616.TXT CUTO_F1_20140603.TXT FA_AUTO_06012014.TXT LA_AUTO_06112014.TXT MA_AUTO_06212014.TXT ZA_AUTO_06232014.TXT Output: AUTO_F1_20140610.TXT... (9 Replies)
Discussion started by: nani1984
9 Replies

5. Shell Programming and Scripting

Convert From Month Number to Month Name

Hi, I have a script that accepts an input date from the user in yyyy-mm-dd format. I need to get the mm-dd part and convert it to month name. example: 2011-11-15 I want that to become "Nov 15" I don't have the GNU date, I am using an AIX os. Thanks. (1 Reply)
Discussion started by: erin00
1 Replies

6. Shell Programming and Scripting

perl : searching for month and storing the date and time in an array

I am writing the code in perl. I have an array in perl and each variable in the array contains the data in the below format Now I need to check the below variable w.r.t system month I need to store the date and time(Tue Aug 7 03:54:12 2012) from the below data into file if contains only 'Aug'... (5 Replies)
Discussion started by: giridhar276
5 Replies

7. Shell Programming and Scripting

Script to counting a specific word in a logfile on each day of this month, last month etc

Hello All, I am trying to come up with a shell script to count a specific word in a logfile on each day of this month, last month and the month before. I need to produce this report and email it to customer. Any ideas would be appreciated! (5 Replies)
Discussion started by: pnara2
5 Replies

8. UNIX for Dummies Questions & Answers

print previous month (current month minus 1) with Solaris date and ksh

Hi folks month=`date +%m`gives current month Howto print previous month (current month minus 1) with Solaris date and ksh (7 Replies)
Discussion started by: slashdotweenie
7 Replies

9. Shell Programming and Scripting

Isolating the Month in Perl

munt=`date '+%m` will isolate the month in digit form 02 = Feb Trying to get the same out of perl just cant see it $stimx = localtime($^T); print ((split/ /,$stimx)); (4 Replies)
Discussion started by: popeye
4 Replies

10. Shell Programming and Scripting

Perl Script : Split given month into weeks

I want to split a given month into weeks. For example if I give the date in dd/mm/yy format say 01/02/08 it should give output in the given format : week1 : start date and end date. week2 : "" week3 : "" week4 : "" (5 Replies)
Discussion started by: khushbu_roy
5 Replies
Login or Register to Ask a Question