Date and time got swapped/interchanged in date time object, python - python-3.x

I had to load data from excel to jupyter nb, and when i loaded date time column and changed to datetime object, (column has dates from 1st oct 2022 to 31st oct 2022) until 12th october the date is showing in yyyy-dd-mm format and 13th till 31st oct is showing in yyyy-mm-dd format. I want to make it all in yyyy-mm-dd format. I cant edit the excel sheet alsothis is how the dataframe looks after loading the data and changing format to datetime
I want to get all dates in yyyy-mm-dd format. I tried some methods but they were changing all the dates at once. I only want to change the dates till 12th oct

Related

Excel - How to convert Day of Week - Mon - Day - UTC - Year to recognizable date in excel

I'm working on a file that pulls data directly from a web source, but I need to calculate time elapsed since a date. The problem is this is the format the date is appearing in:
Sun May 08 00:00:00 UTC 2016
How to I convert this automatically to MM/DD/YYYY when I refresh the data so that it appears as:
05/08/2016
use:
=--(MID(A1,9,2)&MID(A1,4,5)&RIGHT(A1,4))
and format the output however you want:

How we can extract Day, Date, Time in Excel which is in the format of following Fri Aug 07, 2020 05:12 UTC?

Long Date
Fri Aug 07, 2020 05:12 UTC
Day | Date | Time |
Friday | 07:10:2020 | 05:12 |
to get the date from that string use:
=--MID(A1,5,LEN(A1)-8)
Put that in three cells. Then format the cells:
day cell: dddd
Date Cell: dd\:mm\:yyyy
Time Cell: HH:MM
You could use the following to put the text string into just a date time format that excel understands:
=DATEVALUE(RIGHT(LEFT(A1,LEN(A1)-4),LEN(A1)-8))
The above will not be affected by number of digits for year, day or hour; only that the bit it is using has 4 chars at the front (Fri and space) and 4 at the end (space and UTC).
Since you have two digits for both day and hour, this could be simplified with using MID, like:
=DATEVALUE(MID(A1,5,LEN(A1)-8))
To extract a date from a text string representing a date, you can use the DATE function e.g. =DATE([year],[month],[day]).
To get those parts from a text string you can use =MID([input text string], [start position], [number of characters]). So you could do MID for each component (year, month etc) needed, then put the results through the DATE function.
Date formats in Excel are distinguished between what is stored and what is displayed.
What is stored depends on your excel settings.
What is displayed depends on your excel settings as well as your "regional and language options" or equivalent settings in your computer's operating system.
To change what is displayed, set a custom format (ctrl-1, first tab, last list item) to something like Ddd Mmm dd, yyyy hh:mm.
Otherwise regional and language options, and program settings, can override how the date is shown (which can be important if you are sharing workbooks, especially with unknown future users).
Is the input UTC or do you need to convert?
If you need to convert, do you have a fixed offset in hours? If so, it is a simple formula. For example: =A1+3/24 for UTC-3 hours.
To change what is stored, first understand whether the number stored represents the number of days since 1 Jan 1901, or 1 Jan 1904, or some other convention (such as 1 Jan 1970).
Then decide if you want to store it as a date or a text string.
Then decide if you want to store it as 3 copies of the same value (each displaying a different aspect: day, date, time) or if you just want each value to be its own part not the whole date "hidden" and the display set.
To store it as a text string, use =TEXT(A1,"Dddd"), =TEXT(A1,"MM:DD:YYYY") and =TEXT(A1,"HH:MM").
Watch out for 24 or 12 hour time: the difference is whether "AM/PM" is appended. Your input is likely 24h time but check another example from the dataset to be sure.

Unix timestamp from csv gives me the same date, although different values

I have a csv file with some columns, like date and time. The date is a 10 digit format, unix format from what i read online.
examples are: 1567285228,1567285348, 1567371053.I found that I can use the formula: =(((A2/60)/60)/24)+DATE(1970,1,1) to calculate the proper date from the code, but the problem is that my csv is for one entire month, the codes are different, but the proper date gives me only 2 values: 01 sept 2019 and 31 aug 2019.
How can I find the REAL dates, for the WHOLE month?
Also, the time when the measurements are taken are for example: 712980, 713040
,713100,713160, but when i use excel to format the time stamp to proper time, it only shows me 12 AM. How can I calculate the proper dates and time, so that I can analyse the data from the csv?

How to convert a String date to a Date

How can I convert this string:
Tue Jan 24 14:59:20 BRT 2017.
Into a date that includes day month year and time and timezone, using Excel functions only.
I have several cells with dates following this format. I have to compute the difference between some of these dates in minutes. I believe that the first step is converting the date to a String to a real date information. Then, I will be able to: order the dates and compute the time between consecutive dates.
Use this formula:
=--(SUBSTITUTE(MID(A1,5,LEN(A1)),"BRT",""))
Then format it to the format you want.
It will now work in math equations.

Excel Date/Time formatting AM vs PM error

I am using Windward to generate a report with readable dates. Winward uses Excel date/time formatting for formatting, however I am experiencing an issue when formatting a date/time within the 12th hour (eg 12:30) showing as AM rather than PM.
Are my Excel input/output date/time format strings incorrect?
Input format
yyyy-MM-dd hh:mm:ss.S
Output format
dd MMM yyyy h:mm AM/PM
Examples
2016-11-24 00:15:00.0 evaluates to 24 Nov 2016 12:15 AM OK
2016-11-25 12:15:00.0 evaluates to 25 Nov 2016 12:15 AM WRONG
2016-11-26 13:15:00.0 evaluates to 26 Nov 2016 1:15 PM OK
The issue isn't to do with the Excel date/time format strings. Windward uses java's SimpleDateFormat class to evaluate date inputs and Excel Date Formatting to output the formatted date. The following input format works correctly.
yyyy-MM-dd HH:mm:ss.S
As per oracle documentation here.
Letter Date or Time Component Presentation Examples
H Hour in day (0-23) Number 0
h Hour in am/pm (1-12) Number 12

Resources