set up proper date format - date-format

in csv file I have column, where are date's with diffrent format as below:
02/03/2014 00:10
1/02/2014 7:25:00
7/03/2013 8:30:00 PM
How to set up proper date into CTL file in SQL-LOADER?
column1 "to_date(:column1, 'DD/MM/YYYY HH24:MI:SS')"

Related

How to convert a text string in Google Sheets to date format

I have a column with dates and time formatted like this in each cell:
Thursday, Jan 21, 2021 4:30 PM-5:00 PM
I want to split this across two columns so that the first column has "DD/MM/YY" and the second has the timeslot.
So it would go from being a cell with:
Thursday, Jan 21, 2021 4:30 PM-5:00 PM
to two cells:
21/01/21 4:30 PM-5:00 PM
What formula can I use in Google Sheets to achieve this?
Another suggestion (which assumes here that your raw data runs A2:A):
=ArrayFormula(IF(A2:A="",,SPLIT(REGEXREPLACE(A2:A,"^\w+, (.+\d) (\d.+$)","$1~$2"),"~")))
This will leave your dates in the first column as numeric raw dates rather than as text, so you'd be able to use them in calculations and comparisons later. Just select the first column of the results (i.e., those raw dates, showing as numbers in th 40000 range) and format the entire column (Format > Number) in the date format you prefer.
use:
=INDEX(IFNA(TEXT({REGEXEXTRACT(A1:A, ", (.+\d{4})")*1,
REGEXEXTRACT(A1:A, "\d{4} (.+)")}, {"dd/mm/yyyy", "#"})))

Convert ISO date format to moment date format

In angular material, used mat-datepicker for showing date picker.
I need to show custom date formatter in that date field.For custom date formatter, I have used material-moment-adpator. But I have ISO date format like this dd-MM-yyy. If use this date format, I get Tu-01-1990 output but I need to get a 10-01-1990.
How to convert iso date format to moment date format?
for "numeric" days, you should use DD instead of dd

how to convert the date format from dd-mmm-yyyy to yyyy-mm-dd in ruby on rails

I am uploading the csv file. The csv file contains the date format in dd-mm-yyyy format. How can I change it to yyyy-mm-dd format. I also tried to_date function but it gives the error as invalid date.
You can do this by below code
require 'date'
date = DateTime.parse("22-02-2019")
formatted_date = date.strftime('%Y-%m-%d')
output
"2019-02-22"
please go through with this document https://www.rubydoc.info/stdlib/core/Time:strftime you will find out the different formatting style

Store Time value string hh:mm AM/PM

I am trying to save a time string in the database in the form of HH:MM AM/PM format. e.g. 12:00 AM to 11:00 PM. These strings are already defined in the code. What is the best data type to store these strings in database using SQL Server 2012.
What is the better way? a generic list in the code to populate values when page loads and then store or store all values in the database from 12:00 AM to 11:00 PM and then get from database.
If you use DateTime or DateTime2 in the database it's a 24 hour clock, there is no AM/PM format. You get an AM/PM format by doing this in the code:
dateTime.ToString("tt", CultureInfo.InvariantCulture);

How to automatically format NOW() in to a string that that displays YYYY-MM-DD?

Is it possible to format the output of NOW() to a string that displays YYYY-MM-DD?
This is the output of NOW(): 29/02/2012 12.07.37
The reason is, that I need to use the current date in a QUERY.
QUERY only accepts date in the format YYYY-MM-DD . I can't get a date directly from a cell, because it gets formatted as (even if I change the formatting): DD/MM/YYYY
Perhaps some regular expression?
If this is supposed to be an in-cell formula then you can use
=TEXT(NOW(),"yyyy-mm-dd")
I will follow JMax's suggestion and convert my comment to an answer.
Now() returns the current date and time as a number. The integer part gives the date and the fraction part gives the time. If you print or display that date, the default is to give the full date in what Microsoft think's is the local format.
Format(expn, fmt) allows you to convert an expression to a string. For example:
Dim DateStg as String
DateStg = Format(Now(),"yyyy-mm-dd")
fmt defines the format to which the expn is to be converted. fmt is a mixture of code letters (such as: "yyyy", "mm", "dd") and punctuation (such as "-"). "yyyy-mm-dd" appears to meet your current needs but you can also usethe following to format dates:
"mmm" to give three letter month (Jan, Feb, etc.)
"mmmm" to give full name of month (January, February, etc)
"ddd" to give three letter day of week (Mon, Tue, etc)
"dddd" to give full name of day of week (Monday, Tuesday, etc)
In VB.net you can do the following:
Dim dateStr As String = Now().ToString("yyyy-MM-dd")
In C# you can do it like this:
String dateStr = DateTime.Now.ToString("yyyy-MM-dd");

Resources