Questions tagged [datetime]

A DateTime object in many programming languages describes a date and a time of day. It can express either an instant in time or a position on a calendar, depending on the context in which it is used and the specific implementation. This tag can be used for all date and time related issues.

A DateTime object in many programming languages describes a date and a time of day. It can express either an instant in time or a position on a calendar, depending on the context in which it is used and the specific implementation.

  • In , os.date and os.time are provided as part of lua's standard library for working with date and time.

  • In the data types TIMESTAMP [WITHOUT TIME ZONE] and TIMESTAMP WITH TIME ZONE are collectively referred to as timestamps. (And the data types DATE, TIME, and TIMESTAMP are collectively referred to as datetime types.)

  • In , datetime is a type that represents a date and time of day. It carries no time zone context, so it is a position on a calendar, not a moment in time.

  • In , DATETIME values represent a date and time of day. They carry no time zone context, so they are positions on a calendar, not a moment in time. TIMESTAMP values represent a moment in time, and are based on UNIX time. When MySQL stores TIMESTAMPs, it converts them from the current connection's time zone setting to UTC. When displaying them it converts them back.

  • In , DateTime is a structure that is typically expressed as a date and time of day. It represents either an instant in time, or a position on a calendar. The precise meaning is dependent on the value of its Kind property.

  • In , Instant is a class that represents an instant in time. Before Java 8 was a popular library, DateTime is a class which represents an instant in time, with reference to a particular time zone.

  • In , datetime is an object which represents a date and time of day. The precise meaning is dependent on the value of its tzinfo property. It is also the name of the module that provides date, time, datetime, and related objects.

  • In the DateTime class is a representation of a instant in time, with reference to a particular time zone.

  • In , the time and date manipulation library datetime-fortran can be used.

  • In , a Date instance represents a single moment in time. Date objects are based on a time value that is the number of milliseconds since 1 January, 1970 UTC. That is, they are UNIX time values in milliseconds.

  • In , the classes "POSIXlt" and "POSIXct" represent calendar dates and times.Subtraction of two date-time objects is equivalent to using difftime. Class "POSIXct" represents the (signed) number of seconds since the beginning of 1970 (in the UTC time zone) as a numeric vector. Class "POSIXlt" is a named list of vectors representing sec, min, hour et al

  • In , Microsoft Excel for Windows uses the 1900 date system, by default. Which means the first date is January 1, 1900. a Date and Time function can be used to manipulate the year/date and time/hour/minutes values. The date/time in Excel is stored as a number. Where the decimal part range from 0.0 to 0.99988426 represent 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.), and the integer part range from 0 to 9999 represent days. But Excel's date representation is slightly off in the first two months of calendar year 1900.


Helpful articles

70365 questions
461
votes
3 answers

In Ruby on Rails, what's the difference between DateTime, Timestamp, Time and Date?

In my experience, getting dates/times right when programming is always fraught with danger and difficulity. Ruby and Rails have always eluded me on this one, if only due to the overwhelming number of options; I never have any idea which I should…
Nick
  • 4,765
  • 3
  • 17
  • 9
454
votes
10 answers

How to get current time in python and break up into year, month, day, hour, minute?

I would like to get the current time in Python and assign them into variables like year, month, day, hour, minute. How can this be done in Python 2.7?
guagay_wk
  • 26,337
  • 54
  • 186
  • 295
454
votes
14 answers

Converting between datetime, Timestamp and datetime64

How do I convert a numpy.datetime64 object to a datetime.datetime (or Timestamp)? In the following code, I create a datetime, timestamp and datetime64 objects. import datetime import numpy as np import pandas as pd dt = datetime.datetime(2012, 5,…
Andy Hayden
  • 359,921
  • 101
  • 625
  • 535
453
votes
5 answers

What's the difference between ISO 8601 and RFC 3339 Date Formats?

ISO 8601 and RFC 3339 seem to be two formats that are common the web. Should I use one over the other? Is one just an extension? Do I really need to care that bad?
Brig Lamoreaux
453
votes
27 answers

Conversion of a datetime2 data type to a datetime data type results out-of-range value

I've got a datatable with 5 columns, where a row is being filled with data then saved to the database via a transaction. While saving, an error is returned: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range…
Gerbrand
  • 5,274
  • 4
  • 29
  • 34
450
votes
29 answers

How to change time in DateTime?

How can I change only the time in my DateTime variable "s"? DateTime s = some datetime;
Santhosh
  • 19,616
  • 22
  • 63
  • 74
446
votes
10 answers

Why does datetime.datetime.utcnow() not contain timezone information?

datetime.datetime.utcnow() Why does this datetime not have any timezone info given that it is explicitly a UTC datetime? I would expect that this would contain tzinfo.
Vitaly Babiy
  • 6,114
  • 4
  • 26
  • 24
441
votes
25 answers

SQL query to select dates between two dates

I have a start_date and end_date. I want to get the list of dates in between these two dates. Can anyone help me pointing the mistake in my query. select Date,TotalAllowance from Calculation where EmployeeId=1 and Date between 2011/02/25 and…
Neeraj
  • 7,945
  • 5
  • 19
  • 9
438
votes
6 answers

How to convert a unix timestamp (seconds since epoch) to Ruby DateTime?

How do you convert a Unix timestamp (seconds since epoch) to Ruby DateTime?
Tronathan
  • 6,473
  • 5
  • 22
  • 24
431
votes
34 answers

Format timedelta to string

I'm having trouble formatting a datetime.timedelta object. Here's what I'm trying to do: I have a list of objects and one of the members of the class of the object is a timedelta object that shows the duration of an event. I would like to…
mawcs
  • 4,357
  • 2
  • 18
  • 7
429
votes
11 answers

Get day of week in SQL Server 2005/2008

If I have a date 01/01/2009, I want to find out what day it was e.g. Monday, Tuesday, etc... Is there a built-in function for this in SQL Server 2005/2008? Or do I need to use an auxiliary table?
aaaa
420
votes
14 answers

How to get milliseconds from LocalDateTime in Java 8

I am wondering if there is a way to get current milliseconds since 1-1-1970 (epoch) using the new LocalDate, LocalTime or LocalDateTime classes of Java 8. The known way is below: long currentMilliseconds = new Date().getTime(); or long…
Georgios Syngouroglou
  • 18,813
  • 9
  • 90
  • 92
418
votes
34 answers

How can I select the first day of a month in SQL?

How can one select the first day of the month of a given DateTime variable? I know it's quite easy to do using this kind of code: select CAST(CAST(YEAR(@mydate) AS VARCHAR(4)) + '/' + CAST(MONTH(@mydate) AS VARCHAR(2)) + '/01' AS DATETIME) This…
Brann
  • 31,689
  • 32
  • 113
  • 162
416
votes
18 answers

How to truncate milliseconds off of a .NET DateTime

I'm trying to compare a time stamp from an incoming request to a database stored value. SQL Server of course keeps some precision of milliseconds on the time, and when read into a .NET DateTime, it includes those milliseconds. The incoming request…
Jeff Putz
  • 14,504
  • 11
  • 41
  • 52
415
votes
26 answers

How to convert local time string to UTC?

How do I convert a datetime string in local time to a string in UTC time? I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future. Clarification: For example, if I have 2008-09-17 14:02:00 in…
Tom
  • 42,844
  • 35
  • 95
  • 101