The birth dates in my Access database are formatted as dd-MM-yy. If the day of the birth is greater than the 12th, it is displayed correctly in my label. But if the day of the birth is 1st to 12th (obviously 12 months), day and month are switched in my label and it screws the Age calculation.
I've set culture="fr-CA" uiculture="fr-CA" and in web.config I have Also did Imports System.Globalization The following doesn't work neither.
<asp:label id="LabelDateOfBirth" runat="server" text='<%# Eval("DateOfBirth", "{0:dd MMM yyyy}") %>' />
Can I add System.Globalization.CultureInfo somewhere in the above code?
CodePudding user response:
Since you putting in and "forcing" the date format as you have?
then that should work just fine.
This VERY MUCH suggests that your base table in Access is not a datetime column, but somehow is a text field. You should thus fix this issue first.
You COULD cast the column into a date, and then use your current format.
So, this should have worked:
<asp:Label ID="Label1" runat="server"
Text='<%# Eval("VisitDate", "{0:dd MM yyyy}") %>'></asp:Label>
but, you could change/try as this:
<asp:Label ID="Label1" runat="server"
Text='<%# Convert.ToDateTime(Eval("VisitDate")).ToString("dd MM yyyy") %>'></asp:Label>
While the above probably will work?
You REALLY but beyond really have to go and check that base table in design mode, and change the data type to a datetime.