Questions tagged [date-and-time]

Questions about Mathematica's date and time functions.

Questions with this tag deal with the various date/time functions, including, but not limited to, the functions DateList[], DateString[], DateDifference[], AbsoluteTime[], Clock[], AbsoluteTiming[], and DateListPlot[].

541 questions
23
votes
11 answers

Determining the week of a year from a given date

Consider the following: AbsoluteTime["17/04/2012",{"Day","/","Month","Year"}]; From my calendar in my office, I know that April 17th is in the 16th week of the year 2012. The Calendar package does not provide a function by which I can determine the…
John
  • 4,361
  • 1
  • 26
  • 41
14
votes
2 answers

UNIX time to DateList

I have data that is timestamped with UNIX time, which is the number of seconds since January 1, 1970 UTC. Unfortunately, it seems that most of the date and time functions in Mathematica are based on the system's local time zone. How can I convert a…
Sean Whalen
  • 375
  • 1
  • 7
13
votes
3 answers

How to count occurrences of Friday 13th

I would like to find a function that will count the number of times Friday 13th happens in a particular calendar year. Does anybody have any hints ? Thank you
user63250
11
votes
2 answers

Does Mathematica have a date region function together with operations like intersection?

Consider the following scenario. Suppose I consider time range from TimeObject[{18,30,0}] to TimeObject[{22,30,0}] on Weekdays and TimeObject[{18,0,0}] to TimeObject[{22,0,0}] on Weekends as peak time for something. Now given a date range…
user13892
  • 9,375
  • 1
  • 13
  • 41
10
votes
1 answer

DateDifference isn't consistent when giving result in years

This isn't really causing me a problem at the moment, but it's weird. Is this documented anywhere? When I ask for the difference in days and then in years between April 1, 2015 and October 1, 2015 the years comes out to be exactly .5, whereas I…
Mitchell Kaplan
  • 3,696
  • 22
  • 34
9
votes
3 answers

EasterSunday replacement in Mathematica 10

The Calendar package, now obsolete, had functionality for "special dates"; in particular, EasterSunday[]. The documentation says it's been subsumed into the Wolfram Language. But it hasn't, at least not to any meaningful degree that I can see. How…
David G
  • 629
  • 4
  • 6
8
votes
1 answer

DateListPlot does not accept PlotRange or GridLine specifications using DateObject

This doesn't work... DateListPlot[{{DateObject[{2014, 1, 1}], 1}, {DateObject[{2014, 1, 2}], 2}, {DateObject[{2014, 1, 3}], 3}}, Joined -> True, GridLines -> {{DateObject[{2014, 1, 2}]}, None}] Neither does…
Ymareth
  • 4,741
  • 20
  • 28
8
votes
2 answers

How can I make Saturdays business days

I'm building my own HolidayCalendar. I want some Saturdays to be business days. But Mathematica considers every Saturday a holiday, even for my HolidayCalendar. For instance, DayRange[DateObject[{2020,1,1}], DateObject[{2020,1,31}], "BusinessDay", …
Y. Kwon
  • 565
  • 2
  • 8
8
votes
1 answer

Rounding datetime objects to a given granularity

How does one round datetime objects to any granularity (eg "Hour","Minute" etc)? What I'm looking for is a function that would do the following: DateRound[DateObject[{2018, 7, 7, 10, 55, 42.}], "Hour"] -> DateObject[{2018, 7, 7, 11, 0,…
Carl Lange
  • 13,065
  • 1
  • 36
  • 70
7
votes
2 answers

DatePlus and DateList are inconsistent with numerical handling of the final element

If you run this code you will see that DatePlus and DateList are inconsistent in the format of the lowest order element of the date list. DatePlus[DateList["2012-1-1" ], {5, "Month"}] === DateList["2012-6-1"] DatePlus[DateList["2012-1-1" ], {5,…
vandel
  • 123
  • 3
7
votes
3 answers

Different results with DateRange and LeapYearsQ in Mathematica 9 and 10

With Mathematica 9.0 for Mac OS X x86 (64-bit) (January 24, 2013) one could use DateRange[{2000}, {2010}, "Year"] to achive {{2000}, {2001}, {2002}, {2003}, {2004}, {2005}, {2006}, {2007}, {2008}, {2009}, {2010}} or leapyears =…
user9660
7
votes
2 answers

How can I round a TimeObject according to a certain interval

I have a TimeObject for 06:52:24, and I'd like to round it to the nearest 15 minutes (in this case 07:00). Is this possible to do in general? I know how to do it manually, by getting the hour part and then rounding the minutes, but I'm hoping to…
Adar Maori
  • 71
  • 1
7
votes
2 answers

What's the reverse of DateValue[..., "YearExact"]?

DateValue[..., "YearExact"] can be used to get a date as an non-integer year. This can be useful for some quick, not necessarily too precise calculations where a partial calendar year is a practical quantity. For instance: DateValue[Today,…
kirma
  • 19,056
  • 1
  • 51
  • 93
7
votes
1 answer

DateDifference inconsistency - feature or bug?

The following code attempts to measure the difference in months between the last day of a year and the first day of a month in the following year. QuantityMagnitude@DateDifference[{2018, 12, 31}, {2019, #, 1}, "Month"] & /@ Range@12 which…
RobertNathaniel
  • 790
  • 4
  • 12
7
votes
2 answers

How to convert date string with fractional seconds to DateObject

I have a date/time string from a data file in the form "2014/01/09 07:24:36:001". I would like to convert it to a DateObject. I cannot do it by hand because I have about a thousand of them. This does not work: DateObject["2014/01/09 07:24:36:001", …
Rudy
  • 125
  • 6
1
2 3 4 5 6 7