Get day of week in SQL Server 2005/2008
Use DATENAME or DATEPART: SELECT DATENAME(dw,GETDATE()) — Friday SELECT DATEPART(dw,GETDATE()) — 6
Use DATENAME or DATEPART: SELECT DATENAME(dw,GETDATE()) — Friday SELECT DATEPART(dw,GETDATE()) — 6
You can just use the pd.Timestamp constructor. The following diagram may be useful for this and related questions.
Use the to_datetime function, specifying a format to match your data. raw_data[‘Mycol’] = pd.to_datetime(raw_data[‘Mycol’], format=”%d%b%Y:%H:%M:%S.%f”)
Sorry, brief moment of synapse failure. Here’s the real answer. require ‘date’ Time.at(seconds_since_epoch_integer).to_datetime Brief example (this takes into account the current system timezone): $ date +%s 1318996912 $ irb ruby-1.9.2-p180 :001 > require ‘date’ => true ruby-1.9.2-p180 :002 > Time.at(1318996912).to_datetime => #<DateTime: 2011-10-18T23:01:52-05:00 (13261609807/5400,-5/24,2299161)> Further update (for UTC): ruby-1.9.2-p180 :003 > Time.at(1318996912).utc.to_datetime => #<DateTime: 2011-10-19T04:01:52+00:00 … Read more
Short Answer This can happen if you do not initialize a value to a DateTime field; the field does not accept NULL values, and it’s a value type, so the default value of the non-nullable DateTime type will be used. Setting the value fixed it for me! Long Answer The value of default(DateTime) is DateTime.MinValue … Read more
have you tried to remove the timezone awareness? from http://pytz.sourceforge.net/ naive = dt.replace(tzinfo=None) may have to add time zone conversion as well. edit: Please be aware the age of this answer. An answer involving ADDing the timezone info instead of removing it in python 3 is below. https://stackoverflow.com/a/25662061/93380
You can’t change a DateTime value – it’s immutable. However, you can change the variable to have a new value. The easiest way of doing that to change just the time is to create a TimeSpan with the relevant time, and use the DateTime.Date property: DateTime s = …; TimeSpan ts = new TimeSpan(10, 30, … Read more
function formatAMPM(date) { var hours = date.getHours(); var minutes = date.getMinutes(); var ampm = hours >= 12 ? ‘pm’ : ‘am’; hours = hours % 12; hours = hours ? hours : 12; // the hour ‘0’ should be ’12’ minutes = minutes < 10 ? ‘0’+minutes : minutes; var strTime = hours + ‘:’ … Read more
The last day of the month you get like this, which returns 31: DateTime.DaysInMonth(1980, 08);
Parsing date and time To create a LocalDateTime object from a string you can use the static LocalDateTime.parse() method. It takes a string and a DateTimeFormatter as parameter. The DateTimeFormatter is used to specify the date/time pattern. String str = “1986-04-08 12:30”; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(“yyyy-MM-dd HH:mm”); LocalDateTime dateTime = LocalDateTime.parse(str, formatter); Formatting date and … Read more