Date.FromText
Δημιουργεί μια ημερομηνία από τοπικές, καθολικές και προσαρμοσμένες μορφές ημερομηνίας.
Syntax
Date.FromText(
text as text,
optional options as any
) as date
Remarks
Creates a date value from a textual representation.
text: A text value to covert to a date.options: An optionalrecordthat can be provided to specify additional properties. Therecordcan contain the following fields:Format: Atextvalue indicating the format to use. For more details, go to https://go.microsoft.com/fwlink/?linkid=2180104 and https://go.microsoft.com/fwlink/?linkid=2180105. Omitting this field or providingnullresults in parsing the date using a best effort.Culture: WhenFormatisn't null,Culturecontrols some format specifiers. For example, in"en-US""MMM"is"Jan", "Feb", "Mar", ..., while in"ru-RU""MMM"is"янв", "фев", "мар", .... WhenFormatisnull,Culturecontrols the default format to use. WhenCultureisnullor omitted,Culture.Currentis used.
To support legacy workflows, options can also be a text value. This has the same behavior as if options = [Format = null, Culture = options].
Examples
Example #1
Μετατροπή "2010-12-31" σε τιμή date.
Date.FromText("2010-12-31")
Result:
#date(2010, 12, 31)
Example #2
Μετατροπή με χρήση προσαρμοσμένης μορφής και της γερμανικής κουλτούρας.
Date.FromText("30 Dez 2010", [Format="dd MMM yyyy", Culture="de-DE"])
Result:
#date(2010, 12, 30)
Example #3
Βρείτε την ημερομηνία στο Γρηγοριανό ημερολόγιο που αντιστοιχεί στην αρχή του 1400 στο ημερολόγιο Χίζρι.
Date.FromText("1400", [Format="yyyy", Culture="ar-SA"])
Result:
#date(1979, 11, 20)
Example #4
Μετατρέψτε τις ιταλικές ημερομηνίες κειμένου με μήνες συντομογραφίας στη στήλη Ημερομηνία δημοσίευσης σε τιμές ημερομηνίας.
let
Source = #table(type table [Account Code = text, Posted Date = text, Sales = number],
{
{"US-2004", "20 gen. 2023", 580},
{"CA-8843", "18 lug. 2024", 280},
{"PA-1274", "12 gen. 2023", 90},
{"PA-4323", "14 apr. 2023", 187},
{"US-1200", "14 dic. 2023", 350},
{"PTY-507", "4 giu. 2024", 110}
}),
#"Converted Date" = Table.TransformColumns(
Source,
{"Posted Date", each Date.FromText(_, [Culture = "it-IT"]), type date}
)
in
#"Converted Date"
Result:
#table(type table [Account Code = text, Posted Date = date, Sales = number],
{
{"US-2004", #date(2023, 1, 20), 580},
{"CA-8843", #date(2024, 7, 18), 280},
{"PA-1274", #date(2023, 1, 12), 90},
{"PA-4323", #date(2023, 4, 14), 187},
{"US-1200", #date(2023, 12, 14), 350},
{"PTY-507", #date(2024, 6, 4), 110}
})
Category
Date