Questions tagged [date-manipulation]
90 questions
1130
votes
29 answers
How to add 30 minutes to a JavaScript Date object?
I'd like to get a Date object which is 30 minutes later than another Date object. How do I do it with JavaScript?

Morgan Cheng
- 73,950
- 66
- 171
- 230
282
votes
4 answers
Python datetime - setting fixed hour and minute after using strptime to get day,month,year
I've successfully converted something of 26 Sep 2012 format to 26-09-2012 using:
datetime.strptime(request.POST['sample_date'],'%d %b %Y')
However, I don't know how to set the hour and minute of something like the above to 11:59. Does anyone know…

user1678031
- 2,925
- 2
- 16
- 15
48
votes
14 answers
Start and end date of a current month
I need the start date and the end date of the current month in Java. When the JSP page is loaded with the current month it should automatically calculate the start and end date of that month. It should be irrespective of the year and month. That is…

Lalchand
- 7,627
- 26
- 67
- 79
44
votes
5 answers
django python date time set to midnight
I have a date time of my django object but it can be any time of the day. It can be at any time through the day, but I need to set my time to 00:00:00 (and another date to 23:59:59 but the principle will be the same)
end_date =…

Designer023
- 1,902
- 1
- 26
- 43
42
votes
9 answers
Simplest way to increment a date in PHP?
Say I have a string coming in, "2007-02-28", what's the simplest code I could write to turn that into "2007-03-01"? Right now I'm just using strtotime(), then adding 24*60*60, then using date(), but just wondering if there is a cleaner, simpler, or…

davr
- 18,877
- 17
- 76
- 99
33
votes
6 answers
Compare two dates Google apps script
What would be the best way to compare two dates?
var int = e.parameter.intlistbox;
var startDate = rSheet.getRange(parseInt(int) + 1 ,1).getValues();
// returns Sat Jun 30 2012 00:00:00 GMT-0300 (BRT)
var toDay = new Date();
// Sat Jun 23 2012…

Jacobvdb
- 1,438
- 1
- 14
- 28
22
votes
2 answers
Return start and end of year given any year
I need two or one (out) C# method that will take any datetime and return the start date of year and end date of year for that year.

abmv
- 7,042
- 17
- 62
- 100
18
votes
4 answers
How to update only the hour from a DATETIME field in MySQL?
I want to update a DateTime column where it will change the hours only without modifying anything else. I can't use to add an interval as the values all are different. There is many different dates too. So need to change the hour of exact desired…

M.A.K. Ripon
- 2,070
- 3
- 29
- 47
8
votes
5 answers
MySQL: How to calculate weeks out from a specific date?
I need to calculate the weeks out from a date in my MySQL select statement. There is a date column in one of the tables, and I need to calculate how many weeks away the date is.
SELECT EventDate, (calculation) AS WeeksOut FROM Events;
Example:
6…

Andrew
- 227,796
- 193
- 515
- 708
8
votes
9 answers
SQL Count for a Date Column
I have a table that containts a set of columns one of it is a Date column.
I need to count how many occurrences of the values of that column refer to the same month. And return if for one month, that count sums more than 3.
For…

Sheldon
- 2,598
- 10
- 27
- 36
7
votes
5 answers
What is the correct end-of-day interpretation?
Over the years I have come across different interpretations of the end of a day.
But what is the correct way of representing it when comparing dates and intervals?
I have found that some people seem to prefer 23:59:59, while others do use…
user122830
6
votes
4 answers
SSMS 2012: Convert DATETIME to Excel serial number
I can't seem to find an answer to this anywhere --- I want to convert a datetime in SQL to the excel serial number.
I'm essentially looking for the DATEVALUE function from excel but for use in SQL
Any ideas on how to do this? thanks

FBeveridge
- 121
- 1
- 2
- 10
6
votes
1 answer
How to merge date and time as a datetime in Google Apps Spreadsheet script?
I've a Date column in 'dd/mm/yyyy' format and Time column in 'HH:MM AM/PM' format in Google App spreadsheet. In app script, I want to join these 2 values as a datetime. How can I do this?
Example- date : 13/12/2010, time : 4:30 PM
Then I want to get…

understack
- 11,212
- 24
- 77
- 100
6
votes
8 answers
Convert MM/DD/YYYY date to Month Day Year
I'm trying to convert a MM/DD/YYYY date to a long date. So for example, 02/12/2013 would convert to something like Tuesday February 12 2013.
I've looked at MomentJS and other JS methods, but nothing really did what I wanted. Or at least, I didn't…

SteveV
- 429
- 3
- 8
- 18
4
votes
1 answer
iOS detect if date is within last week
I am trying to detect is a specific date is within the last 7 days (within the last week).
I have found a method to do that, but its eating my performance in a tableview (chat controller).
The code is posted below, and i know it can be done a LOT…

B-Man
- 2,209
- 3
- 22
- 35