---
title: Date.From – แปลงข้อมูลต่างประเภทเป็นวันที่
url: https://www.thepexcel.com/functions/power-query/date-functions/date-from/
type: function-explainer
program: Power Query
syntax: "= Date.From(value as any, optional culture as nullable text) as nullable date"
date: 2025-12-03
updated: 2025-12-23
scores:
  popularity: 8
  difficulty: 2
  usefulness: 8
---

# Date.From – แปลงข้อมูลต่างประเภทเป็นวันที่

> Date.From แปลงข้อมูลหลายรูปแบบ (ข้อความ ตัวเลข DateTime DateTimeZone) เป็นค่า date ที่สามารถใช้ในการ

## คำอธิบาย

Date.From แปลงข้อมูลหลายรูปแบบ (ข้อความ ตัวเลข DateTime DateTimeZone) เป็นค่า date ที่สามารถใช้ในการคำนวณและจัดรูปแบบได้ รองรับการระบุ culture สำหรับการแปลงวันที่ localized

## Syntax

```excel
= Date.From(value as any, optional culture as nullable text) as nullable date
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| value | Yes | any |  | ค่าที่ต้องการแปลง ยอมรับ text datetime datetimezone number หรือ date |
| culture | No | text | null (ใช้ default culture ของระบบ) | รหัสภาษา/วัฒนธรรม เช่น 'en-US' 'de-DE' 'fr-FR' ใช้เมื่อข้อความวันที่ถูกเขียนตามรูปแบบ localized |

## เคสการใช้งาน

### ตัดเวลาออกจาก DateTime

แปลงคอลัมน์ที่มีทั้งวันที่และเวลา ให้เหลือแค่วันที่

### แปลงข้อความเป็นวันที่

แปลง "2025-12-31" ให้เป็นชนิดข้อมูล Date ที่ถูกต้อง

### แปลงตัวเลขเป็นวันที่

แปลง Serial Number ของ Excel (เช่น 45658) ให้เป็นวันที่

## ตัวอย่าง

### 1. แปลง DateTime เป็น Date (ตัวอย่างพื้นฐาน)

```excel
= Date.From(#datetime(1899, 12, 30, 06, 45, 12))
```

**ผลลัพธ์:** `#date(1899, 12, 30)`

เมื่อมี DateTime value ที่มีเวลา ฟังก์ชัน Date.From จะตัดส่วนเวลาออก และเหลือเพียงส่วนวันที่ เหมาะสำหรับเวลาที่ไม่ต้องการเก็บ time component

### 2. แปลงตัวเลข (OLE Automation) เป็น Date

```excel
= Date.From(43910)
```

**ผลลัพธ์:** `#date(2020, 3, 20)`

ตัวเลข 43910 แทนจำนวนวันตั้งแต่ 30 ธันวาคม 1899 (วันที่ 0) การใช้ Date.From จะคำนวณเป็นวันที่ที่ถูกต้อง ระบบเดียวกับ Excel serial dates

### 3. แปลง Text วันที่ที่มี Culture เป็น Date

```excel
let
    GermanDate = "20 Januar 2023",
    Result = Date.From(GermanDate, "de-DE")
in
    Result
```

**ผลลัพธ์:** `#date(2023, 1, 20)`

โดยการกำหนด culture เป็น 'de-DE' Power Query จึงเข้าใจว่า 'Januar' หมายถึง January (มกราคม) และแปลงเป็นวันที่ที่ถูกต้อง ส่วนตัวผมใช้วิธีนี้สำหรับข้อมูล localized จากแหล่งต่างประเทศ

### 4. ใช้ Date.From ในการแปลงคอลัมน์ในตาราง

```excel
let
    Source = Table.FromRows(
        {{"2024-01-15", 100}, {"2024-02-20", 200}, {"2024-03-10", 150}},
        {"DateText", "Amount"}
    ),
    ConvertedDates = Table.TransformColumns(
        Source,
        {"DateText", each Date.From(_), type date}
    )
in
    ConvertedDates
```

**ผลลัพธ์:** `ตาราง 3 แถว คอลัมน์ DateText เปลี่ยนจากข้อความเป็น date type ได้สำเร็จ`

ใช้ Table.TransformColumns ร่วมกับ Date.From เพื่อแปลงคอลัมน์ทั้งหมด ฟังก์ชัน each _ อ้างถึงค่าในแต่ละแถว นี่คือวิธี standardize data types สำหรับคอลัมน์วันที่

## หมายเหตุเพิ่มเติม

- ถ้ารูป format ของข้อความวันที่ไม่ standard เช่น '15-Jan-2024' ให้ลองใช้ Date.FromText ซึ่งให้ควบคุม format มากขึ้น

- เมื่อจัดการ DateTime values ที่มี timezone information ให้ใช้ DateTimeZone.RemoveZone() ก่อน Date.From เพื่อหลีกเลี่ยง unexpected results

- ใช้ Date.From ร่วมกับ try...otherwise เพื่อจัดการข้อมูล malformed อย่างสวยงาม เช่น try Date.From(value) otherwise null

- สำหรับข้อมูล localized ให้ระบุ culture ชัดเจน ไม่ควรพึ่ง default culture ของระบบเพราะแตกต่างในแต่ละเครื่อง

- เมื่อแปลงตัวเลขจากระบบเก่า (dBase FoxPro) ที่ใช้ OLE Automation date ให้ใช้ Date.From สำหรับความสอดคล้อง

## คำถามที่พบบ่อย

**Q: Date.From กับ Date.FromText ต่างกันอย่างไร?**

Date.From ยอมรับข้อมูลหลายประเภท (text datetime number datetimezone) ส่วน Date.FromText ต้องการ text เท่านั้นแต่ให้ control format ที่ละเอียดกว่า ถ้า input เป็นหลายประเภท ให้ใช้ Date.From

**Q: ถ้า input เป็น null จะเกิดอะไร?**

Date.From จะคืน null กลับมา ไม่เกิด error ทำให้สะอาดเมื่อมีข้อมูลที่ขาดหายไป

**Q: OLE Automation date (ตัวเลข) นับจากวันไหน?**

นับจาก 30 ธันวาคม 1899 เป็นวันที่ 1 ซึ่งเป็นมาตรฐาน Excel ด้วย วันที่ 43910 = 20 มีนาคม 2020

**Q: Culture code มี option อะไรบ้าง?**

ตัวอย่าง en-US (องเกิษฐ์) de-DE (เยอรมัน) fr-FR (ฝรั่งเศส) ja-JP (ญี่ปุ่น) th-TH (ไทย) zh-CN (จีนแบบจำหน่าย) เป็นต้น

## ฟังก์ชันที่เกี่ยวข้อง

- [Date.FromText – แปลงข้อความเป็นวันที่](https://www.thepexcel.com/functions/power-query/date-functions/date-fromtext/)
- [DateTime.From – แปลงค่าเป็น DateTime](https://www.thepexcel.com/functions/power-query/datetime-functions/datetime-from/)
- [DateTimeZone.From – แปลงค่าเป็น DateTimeZone](https://www.thepexcel.com/functions/power-query/datetimezone-functions/datetimezone-from/)
- [Text.From – แปลงค่าเป็นข้อความ](https://www.thepexcel.com/functions/power-query/text-functions/text-from/)

## แหล่งข้อมูลเพิ่มเติม

- [Microsoft Learn - Date.From](https://learn.microsoft.com/en-us/powerquery-m/date-from) _(official)_
- [Microsoft Learn - Date.FromText](https://learn.microsoft.com/en-us/powerquery-m/date-fromtext) _(official)_
- [Microsoft Learn - Text.Split and locale-specific parsing](https://learn.microsoft.com/en-us/powerquery-m/text-split) _(official)_

---

_Source: [https://www.thepexcel.com/functions/power-query/date-functions/date-from/](https://www.thepexcel.com/functions/power-query/date-functions/date-from/)_
