Questions tagged [date-arithmetic]

The term 'date-arithmetic' refers to determining via code such information as how many days, hours, etc. between two calendar dates, and determining the last day of the month, or whether a date is a weekday or a weekend. Be sure to also include the appropriate programming or database tag.

Many computer languages provide for date arithmetic, including , , and languages. Most languages store data with a type of date internally as a number of days since a certain date, such as January 1st 1970 for Unix.

Typical Considerations

  • Basic calculations such as number of days between two dates, number of months between two dates, etc.
  • Scheduling problems often involve how to determine the fifth business day of the month, the last day of the month, the fourth Thursday of the month
  • Regional or Client-specific concerns include whether certain days are holidays, etc.
  • Week number of the year (ISO: Monday as first day of week, Unix: Sunday as first day of week)
1101 questions
-1
votes
2 answers

Is there a way to calculate date based on age number?

I have a function which calculates age from a given date public function showAge() { if ($this->account_id == 1 && !empty($this->profile->birthday)) { return date_diff(date_create($this->profile->birthday),…
Web Student
  • 735
  • 3
  • 15
  • 27
-1
votes
1 answer

How to calculate difference between rows of csv file with python

I am new to Python. I would like to do the difference between two rows of a csv file when they have the same id. This csv dataset is built from an sql table export which has more than 3 millions rows. This is an example on how my timeserie's…
-1
votes
1 answer

Rails Show Age in View based Born Date

I have a problem to show age in a view with rails i think this to solve: show.html.slim `=@people.date_born - Date.today / 365,25` `end` What i need to do?
user3856982
-1
votes
1 answer

How to convert values in a specific column in a csv in python?

I have a csv file with a lot of data I am looking to edit. I have a column (DJ in excel) that I need to multiply the numbers in the cells by 1.12. I was wondering how I could do that as I have 3800 rows in that single column. Would I have to read…
user3822682
  • 3
  • 1
  • 4
-1
votes
1 answer

Calculate how many days between 2 dates (one date may be blank) Google Spreadsheets

In Google Spreadsheets, I am trying to list how many days a repair has been in our shop. So, we have a column to enter when the item arrives. We also have a column that I want to show "how many days" has the item been in for repair. The arrival…
RichGee
  • 3
  • 2
-1
votes
1 answer

calculate time to arrive in a procedure

I want to determine necessary time to execute a procedure, time value must be returned in the first instruction in this procedure, like this: procedure myProcedure; begin // determine necessary time here //other instructions end; First, of…
Safa
  • 485
  • 2
  • 5
  • 24
-1
votes
3 answers

Calculate Age with months and years in SQL

I do have a requirement like I need to calculate a person age with sysdate. Calculating the persons age should be exactly greater or lesser than 75years and 09 months with the sysdate. but at some scnearios its not working out. can any one of help…
-1
votes
2 answers

MySql Date range manipulation

Table…
Bergkamp
  • 599
  • 2
  • 6
  • 22
-1
votes
3 answers

C# DateTime subtraction hours from an DateTime Variable

I want to compare to dates like : I have an Variable DateTime, and I want compare if the TIME of this variable is smaller than actual TIME ... ex: Datetime DateT = new DateTime.Now; string Myvariable = "13:00:36";
-1
votes
2 answers

Creating trigger for date of Birth

Please can someone enlighten me on how to create trigger for date of birth having upper limit of 60 and lower limit of 20. I am working on an assignment that requires constraint on staff age range for a shipping company on oracle 11g. thank you
-1
votes
1 answer

Prevention triggers

I have a table like this: StudentID Student Name Birthdate Student Birthplace Gender Height Weight --------- --------------- --------- ------------------ ------ ------ ------ 83 Adam Stone 30-JUN-94 Towson, USA M 193 …
Apple.
  • 117
  • 2
  • 4
  • 12
-1
votes
2 answers

How to find the difference between two timestamp column

I have table name Record which has the following columns, Empid in number column, dat in timestamp Which has the following values empid dat ====== ==== 101 4/9/2012 9:48:54 AM 101 4/9/2012 9:36:28 AM 101 4/9/2012 6:16:28 PM 101 …
Gurujothi.D
  • 1,446
  • 1
  • 12
  • 10
-2
votes
2 answers

Filling in Missing Dates & Assigning Fiscal Period

The table that currently captures the fiscal periods for our accounting software only includes the END date for each period. I need a query result that fills in all missing dates AND accurately assigns their fiscal period as well. For instance,…
-2
votes
2 answers

How to Subtract 30 days from current date in SQL?

I am trying to subtract 30 days from a date column in my database and use that as a condition in my where but I can't get it to work table example: Fact_day 2022-05-20 2022-05-20 2022-04-15 2022-05-28 My trial: where pr.fact_day…
-2
votes
2 answers

SQL difference between two datetime columns

I have a dataset with 2 columns of datetime datatype as shown here: I want to take the difference between the two dates and I try it with this code: Select *, original_due_date - due_date as difference from Table However I'm not…
Sid
  • 163
  • 7