Date format error in database

Hi,

I created a new Collection and straight away (without creating column headers) I imported data (CSV file) and while importing I chose data type for each column, for dates I chose the format as DD/MM/YYYY HH:mm and imported my data. After importing, a yellow exclamation mark appears
in the date column, at each date value,


When I connect a table to this database and try to display the date in the table I get the following error.

I chose format DD/MM/YYYY HH:mm while importing the CSV file, even though my file does not contain time, because there was no format available without time while importing. However, I try adding time to my CSV file to check if that will fix the error but it didn’t.
What could be the possible issue? Can somebody help me on this?

The easiest way is to use dates in this format:
YYYY-MM-DDTHH:MM:ss.sssZ

For example:
2020-05-18T14:06:00.000Z

Open the csv file in MS Excel, convert to this format and import to your collection.

That’s awesome, it worked.

Hi,

After changing as you said, everything worked well within the database.
Today when I connect the database to a repeater the date in the text field show as seen in the following screenshot. I do not want it in that format. How to change it when it displays.

following is the line of code I used.

$item("#rpt2Date").text = itemData.bDate.toString();

The shortest way to do that is to use the .toLocaleDateString() method :

$item("#rpt2Date").text = itemData.bDate.toLocaleDateString();

That’s for date. If you want to display date + time:

$item("#rpt2Date").text = itemData.bDate.toLocaleDateString() + " " + itemData.bDate.toLocaleTimeString();

However, if you have many items in your repeater, and you care about the performance, you can do it that way:

function fromatTime(date){
    return new Intl.DateTimeFormat().format(date) + " " + new     Intl.DateTimeFormat('default', {hour: 'numeric', minute: 'numeric'}).format(date);
}

//inside the repeater.onItemReady():
$item("#rpt2Date").text = fromatTime(itemData.bDate);

Thank you so much. I worked. Your answers are very clear and easy to implement for a beginner like me.

I have one quick question,
In the custom format can we format it to whatever way we want?
I want dd-mmm-yy .
What I got when I use the formatTime(date) function is m/dd/yyyy.
I do not like to use ‘/’ in dates. I want to use ‘-’ instead.

Also, I do not want time with it.

Hello sir , In my database services booking date is correctly submitting . But after the export data is not correct. Its shows previous date . Please help me in that. How can i solve this.


From database (date is 6 Jan 2023)12.00 AM

After exporting ( its 5 Jan 2023)12.00 AM